Skip to main content
Glama
time.ts927 B
export async function getTimeInfo(format: string = "iso") { const now = new Date(); const timeInfo = { timestamp: now.getTime(), iso: now.toISOString(), locale: now.toLocaleString(), utc: now.toUTCString(), timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, timezoneOffset: now.getTimezoneOffset(), year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), dayOfWeek: now.toLocaleDateString('zh-CN', { weekday: 'long' }), }; // 根据格式返回不同的结果 if (format === "unix") { return { timestamp: timeInfo.timestamp, timezone: timeInfo.timezone, }; } else if (format === "locale") { return { locale: timeInfo.locale, timezone: timeInfo.timezone, dayOfWeek: timeInfo.dayOfWeek, }; } return timeInfo; }

Implementation Reference

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/pepedd864/agent-sense'

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