Thursday 1 March 2012

The real doomsday date is Tue Jan 19 2038 at 03:14:07

Some said it was the Y2K bug we had to worry about, but it's actually Tue Jan 19 2038 03:14:07 you've really to worry about.

There are many, many systems built with time saved as a 32bit long integer value.
The max value of a signed long integer is 2147483647. This value is the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC)

Here is an example C program, built with Visual Studio 2010.

__time32_t t;

t = 0;
printf( "The min is %s\n", _ctime32( &t ) ); 

t = 2147483647;
printf( "The max is %s\n", _ctime32( &t) ); 

t = 2147483648;
printf( "The date is %s\n", _ctime32( &t) ); 

Output:
The min is Thu Jan 01 00:00:00 1970
The max is Tue Jan 19 03:14:07 2038
The date is (null)

So after Tue Jan 19 03:14:07 2038, the date goes to null which will cause a crash. Let's just hope all the critical (including embedded) systems get fixed before then.