简体   繁体   中英

How to calculate the time duration between two unix time stamps in php?

I have two time stamps from an API and i wanted to calculate the duration based on that times.

I have streaming which has a start date and an end date as unix time stamp as follows:

"startTime": 1489041394000,
"endTime": 1489041538000

From this times how can i calculate the duration of this video using php?

Try this code

$startTime = 1489041394000;
$endTime = 1489041538000;
$duration = $endTime - $startTime;
$durationInTimeFormat = date("H:m:s", $duration); //
$sec = intval($duration % 60);
echo $sec;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM