Unix Time reaches 1.7 billion
epochconverter.com
epochconverter.com
Woah, is that weird that it's exactly on the hour? ...I guess not so weird, since 180 is divisible by 60.
By way of analogy, imagine we implemented leap years by slowing our clocks to half speed on Feb 28 instead of adding a Feb 29.
Thanks I will imagine this! Too bad we can’t slow the real Earth time down and have a bizarrely slow and long day every 4 years.
But it would matter if I wanted something to take 60mins and then set a start time and an end time.
Dates and timezones are the worst! :-)
You can do things like find midnight GMT by checking (t % 86400 == 0) for example.
In fact, UTC will change its leap second logic much sooner than Unix time logic, so UTC logic will be more like Unix time.
This. If anyone is interested in a source:
https://www.scientificamerican.com/article/the-leap-seconds-...
When you run "date", it asks the system for this number of seconds, then uses a database to look up what that number corresponds to in the local timezone, accounting for leap years and seconds, and spits out that value. So when (some of us) recently "fell behind", the Unix time incremented by 1 second, but that database told us that the time had decreased by an hour.
Not exactly sure how Windows does it, but I recently set up monitoring of a job that Task Scheduler runs, starting at midnight and running for 1 day, every 5 minutes. I got paged at 11:30 because the scheduler decided "1 day" is "24 hours", and it stopped running it at 11pm because of the time change, but didn't start the one for the next day.
I know cron can be confusing, but I'll take it any day over this.
Wrong. UNIX time is number of days since epoch × 86400 + seconds since beginning of day.
In real world some days have been actually 86401 seconds long, which means that UNIX timestamp is (currently) 37 less than number of seconds since epoch.
If you're dealing with human activity, UTC will usually be the easiest choice. If you're just dealing with computers, TAI (or one of its fixed-offset variants like UNIX time) will usually be the easiest choice.
Wrong again. UNIX time definitely is not fixed offset from GPS time. Here is handy dandy conversion tool between the two: https://bag-of-tools.com/gps-time-converter/
1700000000 UNIX = 1384035218 GPS
700000000 UNIX = 384035207 GPS
You'll also need to correct it in the time(2) man page, which says:
"number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)." (ubuntu 22.04)
POSIX.1 defines "seconds since the Epoch" using a formula that
approximates the number of seconds between a specified time and
the Epoch. [...] This value is not the same as the actual number of
seconds between the time and the Epoch, because of leap seconds
and because system clocks are not required to be synchronized to
a standard reference [...] see POSIX.1-2008
Rationale A.4.15 for further rationale
https://man7.org/linux/man-pages/man2/time.2.html#VERSIONSThe word approximates is carrying a lot of weight here. So basically "seconds since the epoch" is a posix codephrase which doesn't actually mean what you'd naively think it does. Why this useful info is buried in the VERSIONS section instead of the main DESCRIPTION I don't know.
For Wikipedia, there is already discussion about the confusing wording of the opening paragraph: https://en.wikipedia.org/wiki/Talk:Unix_time#Flat_out_wrong? but the body of the article is mostly better, and especially the table showing what happens during leap second should clarify matters.
The Unix timestamp will begin with 17 this Tuesday - https://news.ycombinator.com/item?id=38222909 - Nov 2023 (75 comments)
Let's restart counting Unix timestamp to from 2020 - https://news.ycombinator.com/item?id=35202256 - March 2023 (21 comments)
Tomorrow the Unix timestamp will get to 1,666,666,666 - https://news.ycombinator.com/item?id=33316429 - Oct 2022 (116 comments)
Happy 1600M epoch second - https://news.ycombinator.com/item?id=24460382 - Sept 2020 (48 comments)
The Unix timestamp will begin with 16 this Sunday - https://news.ycombinator.com/item?id=24452885 - Sept 2020 (203 comments)
Unix Time 1500M – Friday July 14 02:40UTC - https://news.ycombinator.com/item?id=14758615 - July 2017 (99 comments)
Today at 16:53:20 GMT, it'll be 1400000000 in Unix time. - https://news.ycombinator.com/item?id=7736739 - May 2014 (57 comments)
Ask HN: What will you be doing when the unix timestamp reaches 1234567890, next friday? - https://news.ycombinator.com/item?id=475437 - Feb 2009 (3 comments)
Interesting. And one of those comments was mentioning an EEEpc. Simpler times indeed.
Seems like HN grew the most between then and 2014, continuing up to 2020
Now I things it should be an occasion to open champagne with fellow developers, as it's rarer than new years!
font-variant-numeric: tabular-nums;
https://developer.mozilla.org/en-US/docs/Web/CSS/font-varian...put another way: I'd get great thrills if any proposal to whatwg had to come bundled with the assembly(perl? bash? pick some language) implementation of any such proposal so the authors share the intellectual load of "but, wait, how would we _implement this_?!"
I still remember when we were at 1.2 billion seconds. Time flies.
While we're still here: my favorite way to appreciate the scale of million and billion is with seconds: 1 million seconds is approximately 12 days, whereas as 1 billion seconds is approximately 31 years.
new Date().valueOf() / 1000
I was counting down by thousands of seconds, rather than millions of milliseconds, which is why I divided instead of using the native js value.Happy 1.7 gigaseconds!
for (const [s, d] of (function*() { while (true) { const m=new Date().valueOf(), s=Math.ceil((m+10)/1000); yield [s, s*1000-m] } })()) { await new Promise(r => { setTimeout(()=>r(), d) }); console.log(s) }
setInterval(() => console.log(Math.ceil(Date.now()/1000)), 1000);0
This could be 0.999s late, but seems good enough for REPL usage
Suit yourself, though.
function t(){let m=Date.now(),s=Math.ceil((m+10)/1000);setTimeout(()=>{console.log(s);t()},s*1000-m)}t()
That maintains the accuracy, but frankly just a 1000ms interval will probably be good enough in most cases, though it’ll drift all over the second (e.g. it loses about a millisecond each tick on my machine under Node), and it’s certainly much simpler to reason about. async function* tickSeconds() {
while (true) {
const m = new Date().valueOf()
const s = Math.ceil((m + 10) / 1000)
await new Promise((resolve, _) => {
setTimeout(() => resolve(), s * 1000 - m)
})
yield s
}
}
for await (const s of tickSeconds()) {
console.log(s)
}
I prefer to inline some obvious stuff that is missing than do a paradigm shift to using callbacks or build up an ad hoc library of misc functions.The trouble is all the old embedded systems, and time_t->i32 casts which are currently fine, but lying in wait…
Similar of course to 32 vs 64 bit file offsets.
This brings back memories of all of the Y2K doomsayers about airplanes falling out of the sky, gas pumps not working, and all of the other just wildly bonkers theories people came up with. Even without the help of social media, these notions spread like wildfire.
We know this because we just changed the clocks to 2000 and things broke...badly.
I work with an electronic health records system. Recently they delivered a patch to customers because on Nov 8th 2023 around 0100 in the morning their time field internally would exceed its number of characters allowed.
This was weird to hear about nowadays but I was still not surprised.
They botched the patch and it was not a good time when it happened.
A big chunk of their older code based systems use an epoch of Mar 1,1980, another newer code chunk uses Mar 1, 1992 as their epoch. And I've been told their newest platform uses yet another epoch, or calculates times in such a way to not be concerned.
So while their patch increased the field size for the seconds counter, it has done so a few times only fixing the fields that use the epoch about to be hit, rather than all of them. In top of that, after the counter grew by a digit on Nov 8th,2023, they then realized, much to many hospital customer displeasure, that not all their code the displayed medical documentation/results, often sorted by most recent, accounted for the field size correctly, requiring two more patches last week.
Math with time is hard, and even harder to know what systems have moved forward with enough future thought to still not have these surprises sitting in wait deep in their codebase.
$ date --date="@2200000000"
Sun Sep 18 07:06:40 PM EDT 2039Edit: nm, I don't want an answer.
> Wednesday May 18 2033 03:33:20 GMT
$ date --date="@1800000000"
Fri Jan 15 03:00:00 AM EST 2027
$ date --date="@1900000000"
Sun Mar 17 01:46:40 PM EDT 2030
$ date --date="@2000000000"
Tue May 17 11:33:20 PM EDT 2033 setInterval(() => console.log(Date.now()), 1);
to watch the transition. Happy 1.7B seconds since Jan 1 1970! async function* seconds() {
while (true) {
const millis = new Date().valueOf()
const seconds = Math.ceil((millis + 10) / 1000)
const delay = (seconds * 1000) - millis
await new Promise(r => { setTimeout(() => r(), delay) })
yield seconds
}
}
for await (const s of seconds()) {
console.log(s)
}>for await (const s of seconds())
I'd hate to be your code reviewer!
Tue 14 Nov 2023 02:13:18 PM PST = 1699999998
Tue 14 Nov 2023 02:13:19 PM PST = 1699999999
Tue 14 Nov 2023 02:13:20 PM PST = 1700000000
Tue 14 Nov 2023 02:13:21 PM PST = 1700000001
Tue 14 Nov 2023 02:13:22 PM PST = 1700000002
Tue 14 Nov 2023 02:13:23 PM PST = 1700000003
TL;DR: never do this
If you are storing the epoch offset in seconds, you could store it as int32 or fixed32 (assuming the range is adequate for your application). But int32 will need 5 bytes, while the fixed32 field would only use 4. So you never save space and always spend time using int32.
Similarly, if you are storing the offset as nanoseconds, never use int64. Except for a few years on either side of the epoch, the offset is always optimal in a fixed64. int64 will tend to be 9 bytes. Fixed64 nanoseconds has adequate range for most applications.
You'll note that the "well-known" google.protobuf.Timestamp message commits both of these errors. It stores the seconds part as a varint, which will usually be at least 5 bytes when it could have been 4, and it stores the nanoseconds separately in an int32, even though this is more or less an RNG and is virtually guaranteed to need 5 bytes, if present. So nobody should use that protobuf.
Thus ends this episode of my irregular advice on how to represent the time.
It's 53, right? Since 1 Jan 1970?
Btw, if you already know that leap second is dead and wondering what happens next, well, they are going to implement leap minute, the good news is you are unlikely to see one in your life time. They are meeting next week to decide on this leap minute proposal.
https://www.nytimes.com/2023/11/03/science/time-leap-second....
Either off-by-n leap seconds don't matter enough, or periodically sync'ing with good NTP authorities mitigate it without undue harm. Or ?
Use TAI if you want a monotonic time. UNIX time and GPS time work too, they're fixed offsets from TAI.
Use UTC if you want a calendar date/time. Most human interactions are with time zones relative to UTC.
Those two cover almost all the cases you'll need.
Use UT1 if you want time that roughly tracks the solar time, averaging out the differences in day length due to earth's tilt & elliptical orbit.
Use apparent solar time if you really care about calculating where the sun is or will be for some reason and can't just point your solar telescope at it.
Use sidereal time if you're trying to calculate where extrasolar objects will be.
Use barycentric coordinate time (TCB) if you're plotting the trajectories of interplanetary spacecraft missions or the ephemerides of planets.
Various religions have their own time standards used to calculate when holidays occur.
There are a few others still usable, even more niche than the above. Use one of the first two and you'll probably be fine.
... two days later all hell broke loose.
Also, this first transition should be less disruptive than any other one, since the unsigned format is backwards compatible with the current signed one in its current usage (positive numbers).
For existing binaries (many of them burned in ROM) it is that much compatible that it will also break at the same time as the current system.
So, you need new binaries. If you do, why limit yourself to 32 bits?
Also, I’m not sure all current usage is for positive numbers, only.
Using time stamps for datetimes isn’t what you should do, but chances are older software does it, anyways, because memory was expensive up to the 1980s, and those dates may have been before 1970.
Your 10_000 th day passes when you're 27.x years old (IIRC). I had a celebration with friends as it seemed more significant than any of the other milestones that are usually celebrated because you won't reach 100_000 and don't remember 1_000. Can recommend!
(It doesn't align with any of the various stardate systems actually used in the different Star Trek series and films, but aesthetically it's similar enough to be fun.)
Exactly my point. The rest of humanity uses year 1 as the epoch.
It's irrelevant to my point though. Just because the standard is used by 99% of people instead of 100% doesn't mean programmers should invent a new one, for the same reason they chose January 1st 1970 and not November 15th 1970 or any other day of the year. There's only one obvious choice.
The rest of humanity uses a variety of reckoning systems:
Notably, the newest entry on that list is "Unix time". Just because there's already more than one entry on the list doesn't mean a small group of people should add another. That's not even "there are now 14 standards" that's just deliberately adding to the pile.
Isn’t this just the “no true scotsman” defense, but for calendars?
There's only two calendars where it's been 2023 years.
Regardless, just because the standard is not used by 100% of humanity doesn't justify programmers coming up with their own calendar instead of using the obvious choice. It's unnecessary.
Arbitrariness aside, some other complications would be (A) having to store 64-bit numbers on very early PDP machines; and (B) the Julian/Gregorian transition
Tue Nov 14 14:13:20 PST 2023
$ date -d @1800000000 Fri 15 Jan 2027 12:00:00 AM PST
At least in my household this is the case…
I lost my 1.6 gigasecond script because it was on a work laptop at a previous role.
Welp, time to wait another 3 years. No way I'm missing the Epochalypse.
Not only that, it's almost 9AM.
Sorry, but I can't see what the big deal is supposed to be. Maybe I'm missing something.
Is live blogging still a thing?