currentDateTime
Obtain the current date and time for any valid IANA timezone. Defaults to UTC if no timezone is provided. Useful for scheduling and timestamp generation.
Instructions
Get Current Date and time for timezone. if timezone is not passed default to UTC
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | The timezone should be a valid IANA timezone name like "America/New_York" or "Asia/Kolkata" |
Implementation Reference
- src/server.ts:99-116 (registration)Registration of the 'currentDateTime' tool via server.tool(), including schema (timezone as optional string) and inline handler using Intl.DateTimeFormat to format the current date/time.
server.tool("currentDateTime", "Get Current Date and time for timezone. if timezone is not passed default to UTC", { timezone: z.string().optional().nullable().describe(`The timezone should be a valid IANA timezone name like "America/New_York" or "Asia/Kolkata"`), }, (data) => { const formatter = new Intl.DateTimeFormat("en-US", { timeZone: data.timezone || "UTC", dateStyle: "full", timeStyle: "long", }); return { content: [{ type: "text", text: formatter.format(new Date()), }] } } ); - src/server.ts:103-115 (handler)The inline handler for currentDateTime. It creates an Intl.DateTimeFormat formatter with the given timezone (or UTC), formats the current date, and returns it as text content.
(data) => { const formatter = new Intl.DateTimeFormat("en-US", { timeZone: data.timezone || "UTC", dateStyle: "full", timeStyle: "long", }); return { content: [{ type: "text", text: formatter.format(new Date()), }] } } - src/server.ts:99-102 (schema)Schema definition for currentDateTime: 'timezone' is an optional nullable string described as a valid IANA timezone name.
server.tool("currentDateTime", "Get Current Date and time for timezone. if timezone is not passed default to UTC", { timezone: z.string().optional().nullable().describe(`The timezone should be a valid IANA timezone name like "America/New_York" or "Asia/Kolkata"`), },