Unix time doesn’t help with timezones… It’s always in UTC.
Unix timestamp is always in UTC which is why it’s helpful. It’s seconds since Jan 1st 1970 UTC. Libraries let you specify timezone usually if you need to convert from/to a human readable string.
Don’t try to write your own date/time code. Just don’t. Use something built by someone else.
…yes that’s why UNIX timestamps are helpful, because it’s a constant standard across all the libraries.
Some systems instead spread a positive leap second across the entire day (making each second a very very tiny bit longer) but technically this violates POSIX since it’s modifying the length of a second.
Unix timestamp is always in UTC which is why it’s helpful.
Any time you show the time to a user, you have to use a timezone. That’s why the unix timestamp has limited usefulness - it doesn’t do a lot on its own and practically all use cases for times require the timezone to be known (unless you’re dealing with a system that can both store and display dates in UTC). Even for things like “add one week to this timestamp”, you can’t do that without being timezone-aware, since it’s not always an exact number of seconds as you need to take Daylight Saving transitions and leap seconds into account.
Then that system should be trashed.
A lot of systems just don’t handle leap seconds well. Many years ago, Reddit was down for four hours because their systems couldn’t deal with leap seconds. Smearing the extra second across the whole day causes fewer issues as software doesn’t have to be built to handle an extra second in the day.
Unix timestamp is always in UTC which is why it’s helpful. It’s seconds since Jan 1st 1970 UTC. Libraries let you specify timezone usually if you need to convert from/to a human readable string.
…yes that’s why UNIX timestamps are helpful, because it’s a constant standard across all the libraries.
Then that system should be trashed.
Careful with the exact phrasing here - while the epoch was at midnight in GMT, the time from which time_t is measured also exists in other timezones.
Then that the library that does it should be trashed.
https://en.wikipedia.org/wiki/Unix_time
UNIX time is trash.
Any time you show the time to a user, you have to use a timezone. That’s why the unix timestamp has limited usefulness - it doesn’t do a lot on its own and practically all use cases for times require the timezone to be known (unless you’re dealing with a system that can both store and display dates in UTC). Even for things like “add one week to this timestamp”, you can’t do that without being timezone-aware, since it’s not always an exact number of seconds as you need to take Daylight Saving transitions and leap seconds into account.
A lot of systems just don’t handle leap seconds well. Many years ago, Reddit was down for four hours because their systems couldn’t deal with leap seconds. Smearing the extra second across the whole day causes fewer issues as software doesn’t have to be built to handle an extra second in the day.