Why does strtotime give different result in different timezone?

前端 未结 6 455
迷失自我
迷失自我 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条回答
  •  盖世英雄少女心
    2020-12-11 18:50

    In short: time zone is considered because the Unix Epoch value is considered in GMT.

    In broader sense 2011-09-19 00:00:00 comes to Bangladesh almost after 6 hours it is 2011-09-19 00:00:00 in GMT zone. Because of this gap, another 21600 seconds have passed in the GMT zone when the same date appears in BD.

    Since the calculation is done in respect to the GMT, you have to add these 21600 seconds to get the actual difference.

提交回复
热议问题