Aerostack
build

datetime-parse Edge Function — Utilities

Utilities

Parse a date string or unix timestamp to a normalised Unix millisecond timestamp and ISO string.

navin @navin verified
Updated Mar 12, 2026
GitHub

Edge function datetime-parse Parse a date string or unix timestamp to a normalised Unix millisecond timestamp and ISO string.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.

terminal — aerostack cli
$ npx aerostack add navin/datetime-parse
smart_toy

Use with AI Assistants

MCP

Connect Claude, Cursor, or any MCP-compatible client — then call this function by slug

① Add MCP Server

Add this once — access all Aerostack functions from your AI tool.

claude_desktop_config.json
{
  "mcpServers": {
    "aerostack": {
      "url": "https://mcp.aerostack.dev",
      "type": "http"
    }
  }
}

② Call this function

Ask your AI to use the call_function tool with this slug:

call_function
call_function({
  slug: "datetime-parse",
  args: {
    "value": null,
    "options": null
  }
})

datetime-parse — Parse date strings to Unix timestamps

Normalise any date string or unix timestamp into a reliable millisecond timestamp and ISO string.


API

POST /api/datetime-parse

Request body

Field Type Required Default Description
value string | number Date string or unix timestamp (s or ms)
options.assumeUtc boolean true Treat date-only strings as UTC

Supported formats

  • ISO 8601: 2024-01-15T10:30:45Z, 2024-01-15T10:30:45+05:30
  • Date-only: 2024-01-15
  • US slash: 01/15/2024
  • Unix seconds: 1705315845 (< 10 digits → multiplied by 1000)
  • Unix milliseconds: 1705315845000

Success response (200)

{
  "success": true,
  "data": {
    "timestamp": 1705315845000,
    "iso": "2024-01-15T10:30:45.000Z",
    "valid": true
  }
}

Error responses

Code HTTP When
INVALID_INPUT 400 Missing value field
INTERNAL_ERROR 500 Unexpected error

Usage

cURL
curl -X POST "$FUNCTION_URL" \
  -H "Content-Type: application/json" \
  -d '{"value": "01/15/2024"}'
Direct import (Node / Bun / Deno)
import { datetimeParse } from '@aerostack/functions/datetime-parse';

const result = datetimeParse({ value: '2024-01-15' });
if (result.valid) {
  console.log(result.timestamp); // 1705276800000
}

Use Cases

  • Normalising date inputs from forms or APIs before storing in a database
  • Converting unix seconds from external APIs to ms for JavaScript Date
  • Validating whether user-provided date strings are parseable

Metadata

upgrade Version 1.0.0
gavel License MIT
language Language typescript
cloud Provider aerostack

Tags

datetime
deployed_code

Build and publish your own functions

Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.

More Utilities Functions

Browse Utilities Functions →

Frequently asked questions

What does the datetime-parse function do? +

datetime-parse is a serverless edge function for utilities automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.

How do I deploy the datetime-parse function? +

Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/datetime-parse ``` It will be live on Cloudflare Workers in seconds.

What runtime does datetime-parse use? +

datetime-parse runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.

Can I customise the datetime-parse function? +

Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.