PHP strtotime returning wrong results

后端 未结 3 1496
再見小時候
再見小時候 2020-12-22 12:28

strtotime(\'3rd January,2010\') returns 1230993600 in GMT+5:30.

While according to this, unix timestamp 1230993600 is 3rd January,2009. So it\'s off

3条回答
  •  时光取名叫无心
    2020-12-22 13:04

    The problem is the , in the date string. It seems to separate date from time elements in your string, as

    echo date('Y-m-d H:i:s', strtotime('3rd January, 2010'));
    

    returns

    2009-01-03 20:10:00
    

    whereas

    echo date('Y-m-d H:i:s', strtotime('3rd January 2010'));
    

    (, removed) returns the correct date:

    2010-01-03 00:00:00
    

提交回复
热议问题