Immediately give an example code:

$time1 = strtotime('+1 week'); $time2 = time() + 3600*24*7; var_dump($time1); var_dump($time2); echo PHP_EOL; var_dump(date('Ymd H:i:s', $time1)); var_dump(date('Ymd H:i:s', $time2)); 

Here are the results:

 int(1459164441) int(1459168041) string(19) "2016-03-28 12:27:21" string(19) "2016-03-28 13:27:21" 

Those. the difference is exactly one hour.

Accidentally stumbled, checked what the test began to fall, there the date was checked.

Interestingly, yesterday and the day before, the week and month ago, the return time was exactly the same!

UPD: The time zone is set to "Europe / London".

  • And if you think? - Ipatiev
  • @ Ipatiev thanks for the tip) Did I answer correctly? - jekaby
  • one
    By the way, my code gives me the same time, which coincides with the current local clock. The latest version time zone files. See also what strtotime gives you (now). the idea is now there is no translation of the arrows, the time should be the same. on the other hand, time should give seconds from 1970 to UTC and translation of seconds to a date is based on the time zone settings - Mike
  • Although apparently in Russia there will be no transition to the summer. it was canceled and not returned yet. There was talk that they wanted to make the transition almost on the second Sunday of March. but it's already gone ... - Mike
  • @Mike In the code, the time zone is set to "Europe / London". If you change to "Europe / Minsk", then the time coincides with the current local and the return time is the same in both cases. In general, I think it's a matter of translating time. - jekaby

1 answer 1

On the night from Saturday to Sunday, March 27, the clock is moved one hour back. The time zone was set to "Europe / London".

Because today is March 21, then in a week it will be March 28. And, accordingly, the time of strtotime('+1 week') already gives the result, taking into account the time transfer one hour ago.

We have already canceled the transfer for summer / winter time in Belarus. In Russia too. On the time zone "Europe / Minsk" and "Europe / Moscow" the return time is the same in both cases.

 $time1 = strtotime('+1 week'); $time2 = time() + 3600*24*7; 

In general, the problem of time differences is related to the time transfer per hour for the specified time zone "Europe / London".

The strtotime function strtotime into account the time zone, but time does not, returns the unix-timestamp.