convert_unix_to_datetime
Convert Unix timestamps to readable date and time formats, supporting timezone adjustments and ISO formatting options.
Instructions
Convert unixtime to datetime time (e.g. 1746627290 to 2025-01-01 01:01:01)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unixtime | Yes | ||
| timezone | No | ||
| isISO | No |
Implementation Reference
- src/index.ts:55-68 (handler)Handler function that converts a Unix timestamp to a formatted datetime string using dayjs, with optional timezone and 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, }, ], }; },
- src/index.ts:50-54 (schema)Zod schema defining 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 using server.tool, including name, description, schema, and inline handler.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, }, ], }; }, );