Okay let me first tell what is the term Y2K38 or Unix Millennium bug or year 2038 problem: Well it is a some kind of computer programming problem with date (something similar like Y2K), says that all programs and software are going to crash on near or after 2038. You will find a Wikipedia definition here. Okay look at some php code and its output:
$timestamp=mktime(0, 0, 0, 01 , 01, 2009); echo date("F j, Y, g:i a",$timestamp); // January 1, 2009, 12:00 am
Well output shows expected result. But notice this code now:
$timestamp=mktime(0, 0, 0, 01 , 01, 2039); echo date("F j, Y, g:i a",$timestamp); //January 1, 1970, 7:00 am
Yes output is little shocking. This is what they are calling Y2K38. I think we don’t need to worry about it too much. We still have enough time to solve this. The code above is tested in php(5.2.9) language. I also tested the same thing in java and there is no such problem i found yet (yes java is great!!! :D).
Calendar cal=Calendar.getInstance(); cal.set(2059,11,1,0,0,0); Date date=cal.getTime(); String output; DateFormat df=DateFormat.getDateInstance(DateFormat.FULL,Locale.ROOT); output=df.format(date); System.out.println(output); //Monday, December 1, 2059
notice input and output(shows as expected). Yes we don’t need to worry about it. If we manage to survive until 2038 we will definitely have a solution by then.
Continue reading “Do you aware of Y2K38?”