PHP:以秒为单位的时差

时间:2017-04-01 01:53:04

标签: php

我想从给定时间得到总秒数,例如下面给出的数据:

$timein=04-01-2017 7:56:37 am;
$timeout=04-01-2017 5:15:17 pm;
$totalseconds= ?

1 个答案:

答案 0 :(得分:3)

PHP code demo

<?php
$time1=strtotime("04-01-2017 7:56:37 am");
$time2=strtotime("04-01-2017 5:15:17 pm");
echo $time2-$time1;