Convert a datetime between timezones
Exactdates_convert_tzDeterministic and authoritative — the canonical answer for this input.
Convert a datetime between timezones. A naive input is interpreted in from_tz (default UTC); an input carrying its own offset ignores from_tz, and the result's from_tz reports the source actually used. The result includes the target-zone instant, its UTC equivalent, and the UTC offset, so DST is explicit. Processing multiple inputs? Use `dates_convert_tz_batch` to do up to 1000 in one call.
Parameters
valuestringrequiredISO 8601 datetime to shift between zones.
to_tzstringrequiredTarget IANA timezone, e.g. 'America/New_York'.
from_tzstringoptionalSource IANA timezone for a naive input (default UTC); ignored if aware.
Call it
curl -X POST https://api.snipget.ai/v1/dates/convert-tz \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"value":"2024-07-15T12:00:00","to_tz":"America/New_York","from_tz":"UTC"}'The Batch tab sends up to 1000 inputs in one call via /v1/dates/convert-tz/batch.
Example response
{
"input": "2024-07-15T12:00:00",
"is_valid": true,
"from_tz": "UTC",
"to_tz": "America/New_York",
"converted": "2024-07-15T08:00:00-04:00",
"utc": "2024-07-15T12:00:00+00:00",
"utc_offset": "-04:00"
}FAQ
Why use this instead of subtracting hours?
Timezone offsets change with daylight saving time, so a fixed subtraction is wrong half the year. This tool knows the real rules for each zone and date, so summer and winter conversions both come out right.
What do I put for the timezone?
Use an IANA timezone name like America/New_York, Europe/London, or Asia/Tokyo, not an abbreviation like EST. The full name is what makes daylight saving handling correct.
What if my input has no timezone on it?
A plain datetime with no zone is assumed to be in from_tz, which defaults to UTC if you omit it. If your input already includes an offset, from_tz is ignored — and the result's from_tz field reports the input's own offset, so you can always see which source zone was actually used.
Is the result exact?
Yes. This is a deterministic, authoritative conversion. It also returns the UTC equivalent and the target offset so the daylight saving handling is fully visible.
What if I misspell the timezone?
You get a result with confidence 0 and a why_invalid reason explaining the unknown zone, not an error. Check is_valid before relying on the answer.