Skip to main content
Glama
joshuaboys

datetime-mcp

by joshuaboys

datetime.parse

Parse date/time strings into standardized timestamps with IANA timezone support for temporal calculations and data processing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesA date/time string parseable by JS Date
tzNoIANA timezone, e.g. Australia/Perth

Implementation Reference

  • Tool registration and handler implementation for datetime.parse.
    server.tool(
      "datetime.parse",
      {
        value: z.string().describe("A date/time string parseable by JS Date"),
        tz: z.string().optional().describe("IANA timezone, e.g. Australia/Perth"),
      },
      async ({ value, tz }) => {
        const zone = tz || DEFAULT_TZ;
        const payload = parsePayload(value, zone);
    
        return {
          content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
        };
      }
    );
  • The logic function parsePayload used by the datetime.parse tool.
    function parsePayload(value: string, tz: string) {
      const d = new Date(value);
      if (Number.isNaN(d.getTime())) {
        throw new Error(
          `Unable to parse date value: ${formatInputForError(value)}`
        );
      }
      return {
        input: value,
        tz,
        utcIso: d.toISOString(),
        epochMs: d.getTime(),
        human: formatHuman(d, tz),
      };
    }
Install Server

Other 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/joshuaboys/datetime-mcp'

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