Skip to content

DateTime

Standard · 1 credit

Parse date strings, convert between timezones, compute diffs, add durations, and count business days.

FieldTypeRequiredDescription
actionstringYesparse, format, convert, diff, add, or business_days
valuestringYesDate/time string or Unix timestamp
value2stringNoSecond date — required for diff and business_days
timezonestringNoIANA timezone for convert (e.g. America/New_York)
durationstringNoGo duration string for add (e.g. 72h, 30m, 24h30m)
output_formatstringNoGo time format layout for format
FieldTypeDescription
formattedstringFormatted date string
parsedobjectParsed date components
parsed.yearintegerYear
parsed.monthintegerMonth (1–12)
parsed.dayintegerDay of month
parsed.hourintegerHour (0–23)
parsed.minuteintegerMinute
parsed.secondintegerSecond
parsed.weekdaystringDay of week
parsed.timezonestringTimezone name
parsed.unix_timestampintegerUnix timestamp
parsed.iso8601stringISO 8601 representation
diffobjectDifference between two dates
diff.daysintegerDays
diff.hoursintegerHours
diff.minutesintegerMinutes
diff.secondsintegerSeconds
diff.human_readablestringHuman-readable duration
business_daysintegerBusiness days between two dates
Terminal window
curl -X POST https://morso.dev/api/datetime \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "parse", "value": "2026-05-06T14:30:00Z"}'
{
"parsed": {
"year": 2026,
"month": 5,
"day": 6,
"hour": 14,
"minute": 30,
"second": 0,
"weekday": "Wednesday",
"timezone": "UTC",
"unix_timestamp": 1778346600,
"iso8601": "2026-05-06T14:30:00Z"
}
}
Terminal window
curl -X POST https://morso.dev/api/datetime \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "convert", "value": "2026-05-06T14:30:00Z", "timezone": "America/New_York"}'
{
"formatted": "2026-05-06T10:30:00-04:00",
"parsed": {
"year": 2026,
"month": 5,
"day": 6,
"hour": 10,
"minute": 30,
"second": 0,
"weekday": "Wednesday",
"timezone": "EDT",
"unix_timestamp": 1778346600,
"iso8601": "2026-05-06T10:30:00-04:00"
}
}
Terminal window
curl -X POST https://morso.dev/api/datetime \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "diff", "value": "2026-01-01", "value2": "2026-05-06"}'
{
"diff": {
"days": 125,
"hours": 3000,
"minutes": 180000,
"seconds": 10800000,
"human_readable": "125 days"
}
}
Terminal window
curl -X POST https://morso.dev/api/datetime \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "business_days", "value": "2026-05-01", "value2": "2026-05-15"}'
{
"business_days": 10
}