Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can I do in my code today, to prevent the unix time stamp running out in 2038?

For example, I mostly program in PHP. What can I do today to prevent my program from exploding in 2038 due to unix time stamp running out? I would love to see some specific algorithms, functions or logics that can work to prevent this problem. Thanks.

like image 350
KoKo Avatar asked Jan 17 '13 19:01

KoKo


People also ask

What happens when Unix time runs out?

One billion seconds (just over 31 years, 251 days, 1 hour, 46 minutes and 40 seconds) after 01:27:28 UTC on 13 May 2006 is beyond the 2038 cutoff date. Thus, after this time, the time-out calculation overflowed and returned a date that was actually in the past, causing the software to crash.

Will Unix time run out?

But if we survive that, Unix and Linux geeks know that the real end of time is waiting just around the corner: January 19, 2038, at 3:14 a.m. UTC.

What is the maximum Unix time?

2,147,483,647 – The End of Time [Unix].

What is Unix timestamp for a date?

Unix time is a way of representing a timestamp by representing the time as the number of seconds since January 1st, 1970 at 00:00:00 UTC. One of the primary benefits of using Unix time is that it can be represented as an integer making it easier to parse and use across different systems.


1 Answers

Store the timestamp as a 64bit, or higher, integer. I'm sure MySQL will be updated by then so that TIMESTAMP isn't 32bit. In regards to PHP, I don't see any issues there if you're on a 64 bit server.

like image 143
Christian Avatar answered Sep 24 '22 14:09

Christian