TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Let's restart counting Unix timestamp to from 2020

2 pointsby touchpadderabout 2 years ago
Old counting start date: Jan 01 1970 01:00:00 GMT+0100<p>New counting start date: Jan 1 2020 00:00:00 UTC+0000<p>Example in Dev Tools how to get the new epoch time<p>const newBeginning = new Date(&#x27;Jan 1 2020 00:00:00 UTC+0000&#x27;)<p>const newEpoch = Date.now() - newBeginning.getTime()<p>console.log(&#x27;New epoch timestamp&#x27;, newEpoch)

5 comments

simonblackabout 2 years ago
Sounds a bit like a solution in search of a problem.<p>There&#x27;s no reason you can&#x27;t use a 64-bit value in a 32-bit system. Much simpler to access the 64-bit value as two 32-bit words than propose a whole new confusing and ambiguous system.<p>In terms of current-time coding, the only time that second hi-order word would be used is when the lo-order word overflows, and on initialisation of the 64-bit variable. And if needs must, it could even be a compiled-in value, seeing it will only change once in every 68 years.
评论 #35203889 未加载
fargleabout 2 years ago
here&#x27;s an idea: instead of projecting a human concept of the <i>roundness</i> of a date onto the technical solution, let&#x27;s use a value optimized for efficient implementation.<p>Obviously if you move toward 64 bits, as most systems have already done, you don&#x27;t have a problem.<p>So if you want to stick to signed 32 bits, let&#x27;s instead agree to restart counting 32 bit UNIX timestamps for the new epoch at exactly Sun Feb 7 06:28:16 AM 2106 UTC.<p>Sure, it&#x27;s not a very round number in human terms, but has the advantage of requiring significantly less implementation.<p>Of course you still have the same problem of knowing which epoch you are in, but that&#x27;s intrinsic to the problem when you only have 32 bits.
评论 #35203954 未加载
tobinfekkesabout 2 years ago
And why not 2000 while you&#x27;re at it, to keep it even?
评论 #35202448 未加载
bell-cotabout 2 years ago
Great idea - for shiny new systems, at new companies, that will never see any date older than Jan 1 2020.<p>But for other use cases - not so great.
评论 #35202874 未加载
victorbjorklundabout 2 years ago
Why?
评论 #35202396 未加载