Get interval seconds between two datetime in PHP?

后端 未结 8 1105
孤街浪徒
孤街浪徒 2021-01-31 07:08

2009-10-05 18:11:08

2009-10-05 18:07:13

This should generate 235,how to do it ?

8条回答
  •  孤城傲影
    2021-01-31 07:29

    PHP Date Time reference is helpful for things like this: PHP Date Time Functions

    strtotime() is probably the best way.

    $seconds = strtotime('2009-10-05 18:11:08') - strtotime('2009-10-05 18:07:13')
    

提交回复
热议问题