Skip to main content
Glama

convert_unix_to_datetime

Transform Unix timestamps into readable date/time formats, including timezone adjustments and ISO compliance, for clear time representation.

Instructions

Convert unixtime to datetime time (e.g. 1746627290 to 2025-01-01 01:01:01)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
isISONo
timezoneNo
unixtimeYes

Implementation Reference

  • Handler function that converts a Unix timestamp to a formatted datetime string using dayjs, respecting timezone and optional ISO format.
    async ({ unixtime, timezone, isISO }) => { const currentDateTime = dayjs .unix(unixtime) .tz(getTZ(timezone)) .format(isISO ? undefined : DEFAULT_TIME_FORMAT); return { content: [ { type: "text", text: currentDateTime, }, ], }; },
  • Zod schema defining the input parameters: unixtime (required number), timezone (optional string), isISO (optional boolean).
    { unixtime: z.number(), timezone: z.string().optional(), isISO: z.boolean().optional(), },
  • src/index.ts:47-69 (registration)
    Registration of the 'convert_unix_to_datetime' tool with name, description, input schema, and handler function using server.tool().
    server.tool( "convert_unix_to_datetime", "Convert unixtime to datetime time (e.g. 1746627290 to 2025-01-01 01:01:01)", { unixtime: z.number(), timezone: z.string().optional(), isISO: z.boolean().optional(), }, async ({ unixtime, timezone, isISO }) => { const currentDateTime = dayjs .unix(unixtime) .tz(getTZ(timezone)) .format(isISO ? undefined : DEFAULT_TIME_FORMAT); return { content: [ { type: "text", text: currentDateTime, }, ], }; }, );
  • Helper function to get timezone, using provided or guessing with dayjs.tz.guess().
    const getTZ = (timezon?: string) => { return timezon || dayjs.tz.guess(); };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/t-shiratori/time-tools-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server