Paul Clarke
Feb 22, 2012
1 min reading time

Party like it’s 2038

In some of our php we run dates through strttotime( ) to turn them from whiffy formats like 12DEC12 to a nice ISO date format of 2012-12-12. Someone here just found a real example of the y2k38 bug live and in the wild. They’d set an expiry date for something of some time in 2050 – you can’t pass a date in 2050 through php’s strtotime(). It suddenly becomes 1970 because 32 bit systems can’t handle timestamps that big. Try it out

for ( $year = 2037; $year <= 2039; $year ++ ) {
 echo "strtotime( $year-01-01 ) is " . strtotime( "$year-01-01" ). ",
( 'Y-m-d', strtotime( $year-01-01 )) is " . date( 'Y-m-d', strtotime(
"$year-01-01" )). "\n";
}

I will hopefully be retired before this is a big issue (in my day we had to worry about the Y1k bug, etc) but hey look out for it.

See strtotime or google ‘y2k38’.

Sorry my first post (our first post?) has to be about php. Honestly I’m working on cutting edge stuff too.

Tags PHP, y2k38