Archives

Archive for December 28th, 2005

The Year 2038 Bug! Recompile before it’s too late!

Wednesday, December 28th, 2005

I was reading this article that claims that we should be prepared for the year 2038 bug! Yeah, you ‘ve heard right! The 2038 bug! After the famous Y2k Bug (a more trendy name for the Year 2000 Bug) there’s a new bug in town! As the article explains:

Time_t is a data type used in C/C and other languages based on C/C to represent/store dates and times internally. Time_t is actually just an integer that counts the number of seconds since January 1, 1970, at 12:00am GMT. If time_t is set to 0, it means the date and time is Jan 1, 1970, 12:00:00am. If the value of time_t is 60, the date and time will be Jan 1, 1970, 12:01:00am, and so on.
On Jan 19, 2038, 03:14:07am GMT, the t_time value will be 2147483647. This is the problem. All 32-bit computer systems store time_t in signed 32-bit integer. In other words, time_t can use a maximum of 32 bits. The first bit is used to indicate positive or negative state of the number, while other 31 bits are used to store the number itself. We can store no more than 2147483647 in 31 bits.

Also a PHP snippet that demonstrates the possibilities of this bug:

/* This is program is written by Amanat Ali Goher */
echo “Current T_time is : “. time() .”<br/>”;
echo “Current Date is : “. date(”r”) .”<br/>”;
echo “Date set : “. date(”r”, mktime(03,17, 07, 01, 19, 2005)) .”<br/>”;
echo “Now Setting Date to : 19-Jan-2038, 03:14:07″;
echo date(”M-d-Y”, mktime(03,17, 07, 01, 19, 2038));

So get ready before all the News Channels start bringing Computer experts to try and explain in plain English how this will affect us.