Today, I met a big monster named Xia lingworm.
He is not proficient in learning because he has fallen into the trap. The pitfalls are dug like this:
In the past, I used the following statements to indicate "tomorrow" and "day after tomorrow" of the current time:
$ Date = date (time + 3600*24 * N );
But this writing method is not safe. Please refer to the example below:
Ini_set ('date. timezone ', 'Europe/Berlin'); echo date ("Y-m-d H: I: s", 1382824800); echo "<br/> "; echo date ("Y-m-d H: I: s", 1382824800 + 1*86400); ini_set ('date. timezone ', 'Europe/Berlin'); echo date ("Y-m-d H: I: s", 1382824800); echo "<br/> "; echo date ("Y-m-d H: I: s", 1382824800 + 1*86400 );
The output result is
00:00:00 23:00:00 23:00:00
The next day was secretly eaten for an hour!
In addition, this will happen in the next 154 days. It will not be "Returned" until 155th days ".
Why does it look like this? After querying the data, we found that the problem was originally caused by timeout,
However, if we do not implement failover in China, this issue will not become a problem for the moment for "Asia/Shanghai.
We recommend that you use more scientific calculation methods for date formatting.
Previously written PHP code may cause a BUG. Here, I apologize to the previous project.