The function to get the day of the week of PHP has limit?

5

I'm making a calendar using PHP and JS and it worked perfectly between the year 1902 until 2037, because from 2038 the function to get the day of the week in PHP returns an incorrect value. Is there any specific reason for this?

Follow the code used in the first image to where it still works and in the second image where it starts to get the wrong value.

In the image where you have the "|" on the left side is the day of the week of the month and on the right side the return of the function below.

function getDayWeek($date){
    return date("w", strtotime($date));
}

    
asked by anonymous 09.07.2018 / 04:41

1 answer

8

Yes, this is called bug of the millennium II or bug of timestamp of Unix or Y2K38 Problem . This is because Unix has determined that the timetable would start on 01/01/1970 and would have precision that would fit in 32 bits, so making the count of how many seconds fit there (just over 2 billion, since it still has the signal), the deadline that can reach is January 19, 2038, well in the beginning of the day.

As people use certain features unaware that they serve a lot of software is bugged , almost all do not know this and now the problem is much more serious than the bug in> the millennium, because even with easy solution it continues to proliferate, we now have perhaps thousands of times more systems running than at the end of the last century, and that most had already been born without the turn of the century problem. It's tragic, but it's the current state of our area where people play programming.

You can not manipulate date / time with anything that works with timestamp , as is the case of strtotime() .

You also have the problem of Y10K , enter other .

    
09.07.2018 / 05:28