4 ms·
Show HN: Making it easier to work with timestamps
At my current job, I've started working a lot with timestamps. I ran into two issues:
1. Timestamps need to be constantly copied to web conversion services, and if you have a lot of timestamps, this gets tiring
2. When there are several time frames, you sometimes have to draw a time line to understand what is happening.
Solution:
1. Create a text field in which you can place many timestamps at once and they will all be converted. You can copy an entire object and all timestamps in it will be converted to dates
2. Make a simple interface so you don’t have to draw a time line by hand every time
I created a small website that helps me with solving my issues - https://debugtimestamp.com/ https://debugtimestamp.com/
Have you encountered similar difficulties? How did you solve them?
I will be grateful for your feedback.
I will be very glad if my service is useful to the community.
- gregjor 2y agoI 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
- warrenm 2y agoHow have I solved this problem? Easy - https://strftime.org https://strftime.org
- JackHor 2y agoThanks, yes, of course, every programming language has tools for converting timestamps. But in my case, the use of such tools was labor-intensive and not justified.