How to Convert Unix Timestamps to Dates and Back
Use the default mode to convert a Unix timestamp into UTC and local date/time values, or switch modes to convert a date string in a recognized format into a Unix timestamp.
What this timestamp converter does
A Unix timestamp is a numeric value representing a point in time. This converter can turn a timestamp into UTC and local date/time representations, or turn a date string in a recognized format into a Unix timestamp. It is useful when checking an API value, reading log data, or preparing a date for a system that expects a timestamp.
Choose the direction that matches your starting value. For a number or numeric text, use timestamp-to-date conversion. For a supported date string, use date-to-timestamp conversion. The result can include formatted date and time values, weekday information, and seconds and milliseconds representations.
How to convert a timestamp
-
Decide which value you have. Use a Unix timestamp when your input is an integer, numeric text, or decimal text. Use the date conversion mode when your input is a date string.
-
Select the matching conversion mode. The default mode converts a timestamp to a date. Select the other supported mode for date-to-timestamp conversion.
-
Enter the value without leaving it blank. For timestamp conversion, integer and string inputs are accepted after surrounding whitespace is trimmed. Decimal text is treated as a fractional timestamp.
-
If you are converting a date to a timestamp, enter one of the recognized patterns:
YYYY-MM-DDTHH:MM:SS,YYYY-MM-DDTHH:MM:SSZ,YYYY-MM-DD HH:MM:SS,YYYY-MM-DD,DD.MM.YYYY HH:MM:SS,DD.MM.YYYY,MM/DD/YYYY HH:MM:SS,MM/DD/YYYY,DD Month YYYY,DD Mon YYYY, orYYYY/MM/DD. TheZform must use a literalZsuffix. -
Run the conversion and review the returned fields. If the input is a timestamp, compare the UTC and local representations when the environment matters. If the input is a date string, check that the resulting Unix timestamp matches the date and time you intended.
How to read the result
A numeric timestamp at or below the millisecond-detection threshold is interpreted as seconds. A value greater than 1,000,000,000,000 is interpreted as milliseconds and divided by 1,000 before conversion. This distinction matters when a value appears much longer than a typical seconds-based timestamp.
Timestamp-to-date results include UTC and local date/time representations. The local result depends on the environment in which the conversion runs, so it may not match the local time on another machine. Date-to-timestamp parsing creates a date/time without an explicit timezone and uses the environment's local timezone. Even when the accepted date text ends in Z, that suffix is a literal format marker rather than timezone-aware parsing.
A blank input, invalid timestamp text, or date text that matches none of the recognized patterns produces an unsuccessful result. Extremely large or unusual numeric inputs may instead raise an exception, so do not treat every possible invalid value as a normal conversion error.
Worked example
A developer is checking whether a seconds-based Unix timestamp from an application log corresponds to the expected date and time.
Enter the numeric value 1700000000 in the default timestamp-to-date mode and run the conversion.
The returned result should contain UTC and local date-time representations plus additional formatted date, time, weekday, seconds, and milliseconds values.
Limitations
- Local date/time output and timestamps created from date strings without an explicit timezone depend on the runtime environment. Blank or unparseable input is unsuccessful, while some extreme numeric inputs may raise an exception instead.
Common errors
- A frequent mistake is entering a date in a format outside the recognized patterns, such as a timezone-aware form not listed above. Corrective action: reformat the value to one of the supported patterns before running the date-to-timestamp conversion.
FAQ
How does the converter distinguish seconds from milliseconds?
A timestamp is treated as milliseconds when it is greater than 1,000,000,000,000; otherwise it is treated as seconds.
Why can the local date and time differ from mine?
The local result depends on the runtime environment, so it can differ from the local time shown in another environment. UTC is provided as a separate representation.
What happens if my date format is not supported?
Date-to-timestamp conversion recognizes only the listed text patterns. If the value matches none of them, the conversion is unsuccessful.