Why does strtotime give different result in different timezone?

前端 未结 6 444
迷失自我
迷失自我 2020-12-11 18:34

I am not sure why strtotime() in PHP returns different result in different timezone even though same date is given as parameter, does anyone know the answer? I

6条回答
  •  -上瘾入骨i
    2020-12-11 18:51

    i think probably there will be one time of each php programmer that this function will make him wants to really understand how actually php works with date and time functions.

    funny this function when you try something like...err...for example, assume that today at this very moment is July 11th, 2012 at 13:00:00 (2012-07-11 13:00:00) and then you try strtotime to find exactly the same moment of the day but for tomorrow:

    $x = strtotime('2012-07-12 13:00:00');
    
    $y = strtotime('+1 Day');
    
    $z = $x-$y;
    

    $x and $y of the above first 2 lines will not return the same thing even you ignore the minute and second counts but $z will be around 25200 or around 7 hours in the difference between this 2 lines if your sever is in somewhere of the USA that the GMT is -5 hours but you browser calls this function from berlin in summer where the GMT is +2 hours... LOL now you can get the idea how php work with this function ;)

提交回复
热议问题