My Blog Menu


Thursday, January 19, 2017

Solution to Y2K38 bug in 32-bit PHP

Y2K38 is a 32-bit PHP but to display year more than 2038, or basically 03:14:07 UTC on 19 January 2038.

But why this bug happen? Well, PHP is based on UNIX system that means using integer as seconds passed from 00:00:00 UTC on 1 January 1970 until now, but the problem is that 32-bit integer can only hold number from -2,147,485,548 to 2,147,485,547, the number will reset to -2,147,485,548 when the maximum number reached, and of course, it will reset the date to 20:45:52 UTC on 13 December 1901.

See this gif:

I have made this fix for PHP, Click Here to download my project.

Q: Why i made this fix when year 2038 is long enough for PHP developer to fix it or in that year 32-bit system will obsolete and not used anymore?
A: Because i'm interested to make this and if old server stand until 2038, they don't have to change.

For more information about this bug in Wikipedia Click Here.

No comments:

Post a Comment