datetime.now
Get the current date and time in any IANA timezone to synchronize operations with the host OS clock.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tz | No | IANA timezone, e.g. Australia/Perth |
Implementation Reference
- src/server.ts:91-98 (handler)Handler for the datetime.now tool which calls nowPayload.
async ({ tz }) => { const zone = tz || DEFAULT_TZ; const payload = nowPayload(zone); return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }], }; } - src/server.ts:86-99 (registration)Registration of the datetime.now tool.
server.tool( "datetime.now", { tz: z.string().optional().describe("IANA timezone, e.g. Australia/Perth"), }, async ({ tz }) => { const zone = tz || DEFAULT_TZ; const payload = nowPayload(zone); return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }], }; } ); - src/server.ts:31-39 (helper)Helper function that generates the payload for datetime.now.
function nowPayload(tz: string) { const d = new Date(); // <-- comes from the host OS clock return { tz, utcIso: d.toISOString(), epochMs: d.getTime(), human: formatHuman(d, tz), }; }