Skip to main content
Glama

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
NameRequiredDescriptionDefault
unixtimeYes
timezoneNo
isISONo

Implementation Reference

  • 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, }, ], }; },
  • 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, }, ], }; }, );

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