Skip to main content
Glama

get_current_date_time

Retrieve the current date and time in a standard format, optionally specifying a timezone for accurate local or global time display.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneNo

Implementation Reference

  • The handler function for the 'get_current_date_time' tool. It uses dayjs to get the current date and time in the specified (or default) timezone, formats it using 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 'get_current_date_time' tool, defining an optional 'timezone' string parameter.
    { 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 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 'getTZ' used by the handler to determine the timezone, defaulting to guessed timezone if not provided.
    const getTZ = (timezon?: string) => { return timezon || dayjs.tz.guess(); };
  • Constant defining the default time format string used in the handler.
    const DEFAULT_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";

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