How to get time difference in milliseconds
Posted
by
jason45
on Stack Overflow
See other posts from Stack Overflow
or by jason45
Published on 2011-01-17T16:10:03Z
Indexed on
2011/01/17
16:53 UTC
Read the original article
Hit count: 171
php
Hi, I can't wrap my brain around this one so I hope someone can help. I have a song track that has the song length in milliseconds. I also have the date the song played in DATETIME format. What I am trying to do is find out how many milliseconds is left in the song play time.
Example
$tracktime = 219238;
$dateplayed = '2011-01-17 11:01:44';
$starttime = strtotime($dateplayed);
I am using the following to determine time left but it does not seem correct.
$curtime = time();
$timeleft = $starttime+round($tracktime/1000)-$curtime;
Any help would be greatly appreciated.
© Stack Overflow or respective owner