Skip to main content
Glama
paladini

devutils-mcp-server

date_to_timestamp

Convert date strings to Unix timestamps for programming and data processing. Supports ISO 8601 and common date formats like '2024-01-15T10:30:00Z' or 'January 15, 2024'.

Instructions

Convert a date string to a Unix timestamp. Accepts ISO 8601 and common date formats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYesDate string (e.g., '2024-01-15T10:30:00Z', '2024-01-15', 'January 15, 2024')

Implementation Reference

  • The handler implementation for date_to_timestamp that parses a date and returns Unix timestamps and ISO string.
    async ({ date }) => {
      const parsed = new Date(date);
      if (isNaN(parsed.getTime())) {
        return {
          content: [
            {
              type: "text" as const,
              text: "Error: Could not parse date string. Try ISO 8601 format: 'YYYY-MM-DDTHH:mm:ssZ'.",
            },
          ],
          isError: true,
        };
      }
    
      const result = {
        unix_seconds: Math.floor(parsed.getTime() / 1000),
        unix_milliseconds: parsed.getTime(),
        iso: parsed.toISOString(),
      };
    
      return {
        content: [
          { type: "text" as const, text: JSON.stringify(result, null, 2) },
        ],
      };
    }
  • The registration of the date_to_timestamp tool in the MCP server.
    // Date to Unix timestamp
    server.tool(
      "date_to_timestamp",
      "Convert a date string to a Unix timestamp. Accepts ISO 8601 and common date formats.",
      {
        date: z
          .string()
          .describe(
            "Date string (e.g., '2024-01-15T10:30:00Z', '2024-01-15', 'January 15, 2024')"
          ),
      },
      async ({ date }) => {
        const parsed = new Date(date);
        if (isNaN(parsed.getTime())) {
          return {
            content: [
              {
                type: "text" as const,
                text: "Error: Could not parse date string. Try ISO 8601 format: 'YYYY-MM-DDTHH:mm:ssZ'.",
              },
            ],
            isError: true,
          };
        }
    
        const result = {
          unix_seconds: Math.floor(parsed.getTime() / 1000),
          unix_milliseconds: parsed.getTime(),
          iso: parsed.toISOString(),
        };
    
        return {
          content: [
            { type: "text" as const, text: JSON.stringify(result, null, 2) },
          ],
        };
      }

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/paladini/devutils-mcp-server'

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