Y2K38 Bug and PHP DateTime Class to the rescue

Are you aware of Y2K38 bug. I guess you are aware of it but do not know it by name. You may know that on 32 bit system, PHP date time can work from 1970 to 2038. 03:14:07 UTC on 19 January 2038 is farthest date you can use to work on PHP with the old date and time function.

PHP has introduced Datetime() class in version 5.2 to solve this problem. Y2K38 bug can bite those who are working on financial data. Suppose pension plan application. It can easily go that long from now!

For newly introduced PHP datetime() to be useful in saving you from Y2K38 bug, you must be in 64-bit OS. Then your system can represent that many seconds that in that long range of date.

For working example to show you how the new DateTime class can save you from the Y2K38 bug, head towards this article. To save you reading that long article again, I want to tell you that if you are using 64-bit OS then try first piece of code and try another piece of code and see the difference. First code give you demo of the bug discussed here and another give you right datetime output, which is a solution to the bug.

  • # 1 - by Rick McKnight

    You’re right, other software that work with future dates will begin developing glitches much earlier. For example, a program that works with dates 20 years in the future will have to be fixed no later than 2018.

Comments are open for an year period. Please, write here on Facebook page.