Skip to main content
Glama

get_current_date_time

Retrieve the current date and time in a specified timezone for accurate timestamping and time-based calculations with the 'Time Tools MCP Server'.

Instructions

Get the current date and time (e.g. 2025-01-01 01:01:01)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneNo

Implementation Reference

  • Handler function that retrieves the current date and time in the specified (or default) timezone using dayjs, formats it with DEFAULT_TIME_FORMAT, and returns it as text content.
    async ({ timezone }) => { const currentDateTime = dayjs() .tz(getTZ(timezone)) .format(DEFAULT_TIME_FORMAT); return { content: [ { type: "text", text: currentDateTime, }, ], }; },
  • Input schema for the tool, defining an optional 'timezone' string parameter validated with Zod.
    { timezone: z.string().optional(), },
  • src/index.ts:91-110 (registration)
    Registration of the 'get_current_date_time' tool on the MCP server, including name, description, input schema, and inline handler function.
    server.tool( "get_current_date_time", "Get the current date and time (e.g. 2025-01-01 01:01:01)", { timezone: z.string().optional(), }, async ({ timezone }) => { const currentDateTime = dayjs() .tz(getTZ(timezone)) .format(DEFAULT_TIME_FORMAT); return { content: [ { type: "text", text: currentDateTime, }, ], }; }, );
  • Helper function to determine the timezone, using provided value or guessing with dayjs.tz.guess(). Used by the tool handler.
    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