datetime-parse Edge Function — Utilities
UtilitiesParse a date string or unix timestamp to a normalised Unix millisecond timestamp and ISO string.
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.
npx aerostack add navin/datetime-parse Use with AI Assistants
MCPConnect 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.
{
"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({
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
Tags
Publisher
@navin verified
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 →datetime-add
by @navin
Add or subtract a duration from a date, supporting units from milliseconds to years with correct month-end handling.
datetime-business-hours
by @navin
Check if a datetime falls within business hours and return the next opening time.
datetime-diff
by @navin
Calculate the difference between two dates in specified units (ms, seconds, minutes, hours, days, weeks, months, years).
datetime-duration-format
by @navin
Format a duration in milliseconds to a human-readable string with long, short, or compact styles.
datetime-format
by @navin
Format a date to a string using format tokens like YYYY-MM-DD HH:mm:ss with optional timezone support.
datetime-relative
by @navin
Format a date as a relative time string like '2 hours ago' or 'in 3 days' using Intl.RelativeTimeFormat.
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.