3 ms·
I have not encountered difficulties with timestamps, because every programming language and every relational database already has tools to convert a Unix timest
by gregjor 2y ago
I have not encountered difficulties with timestamps, because every programming language and every relational database already has tools to convert a Unix timestamp to a display date in a given timezone.
A timestamp is defined as the number of seconds since 00:00:00 UTC on Thursday, 1 January 1970. That means any integer is a valid timestamp, not just integers with exactly 10 or 13 digits.
The bash shell for Linux, and I'm guessing every shell, has a way to easily convert a timestamp, including converting to any timezone. Obviously you can script this.
$ date -d @1714901488
Sun May 5 16:31:28 +07 2024
$ TZ=America/Los_Angeles date -d @ 1714901488
Sun May 5 02:31:28 PDT 2024
So that's what I do, or use whatever programming language I'm in. From a web browser I can do it with Javascript in the JS console:
> dt = new Date(1714901488 * 1000) // multiply by 1000 because JS Date takes ms
> dt->toDateString()
"Sun May 05 2024" = $3
> dt->toTimeString()
"16:31:28 GMT+0700 (Indochina Time)"
I normally encounter timestamps in relational databases. Every relational database I've used converts timestamp values to displayable dates/times, with functions for timezone conversion and specific formatting.
- JackHor 2y agoThank you very much for sharing your experience, it will be useful for me. Thanks for pointing out the inaccuracies in the validation - this is very valuable to me