Is the PHP Day of the Week feature limited?

Asked

Viewed 477 times

6

I am making a calendar using PHP and JS and worked perfectly between 1902 and 2037, because from 2038 the function to catch the day of the week in PHP returns an incorrect value. Is there a 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 pick up the incorrect value.

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

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

Calendário até o mês que roda normalmente

Calendário a partir do mês que código retorna valor incorreto

1 answer

8


Yes, it does, it’s called bug millennium II or bug of timestamp unix or Y2K38 Problem. This is because Unix determined that the time would start on 01/01/1970 and would have an accuracy that would fit in 32 bits, so counting how many seconds fit there (just over 2 billion, since it still has the signal), the deadline that can be reached is January 19, 2038, right at the beginning of the day.

How people use certain features without knowing what they serve a lot of software is bugle, almost all do not know this and now the problem is much more serious than the bug of the millennium, because even having an easy solution it continues to proliferate, now we 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 problem of the turn of the century. It’s tragic, but it’s the current state of our area where people play at programming.

You cannot manipulate date/time with anything that works with timestamp standard, as is the case with strtotime().

There is also the problem of Y10K, amid others.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.