cell Posted December 17, 2006 Share Posted December 17, 2006 Hi everybody;i've been looking for a similar post here, but couldn't find any answer... the thing is simple.i have 2 dates in "MINUTES:SECONDS:MSECONDS" format, which I read as strings. I conver them to time and substract. The time difference is what I need.A sample:[code]$dif = strtotime($globalCUE['timeIndex'][$z]) - strtotime($globalCUE['timeIndex'][$z-1]);[/code][b]everything is fine if MINUTES <= 60[/b]. but this is a CD CUE sheet and it's likely to get input values like "[b]64:12:00[/b]". in this case the function freaks out and returns nothing. any other idea that comes to your mind? any workaround? I guess it can't be that hard...thanks! Link to comment https://forums.phpfreaks.com/topic/31007-solved-strtotime-difference-between-2-timestamps/ Share on other sites More sharing options...
Psycho Posted December 17, 2006 Share Posted December 17, 2006 Off the top of my head, I would convert everything to a single time parameter (either seconds or milliseconds) then subtract and convert back. May not be the most efficient method, but the most straitforward.$time1Ary = array_reverse(explode(":",$globalCUE['timeIndex'][$z]));$time2Ary = array_reverse(explode(":",$globalCUE['timeIndex'][$z-1]));$time1 = $time1Ary[0] + $time1Ary[1]*60 + $time1Ary[2]*3600;$time2 = $time2Ary[0] + $time2Ary[1]*60 + $time2Ary[2]*3600;$dif = $time1 - $time2; //Difference in milliseconds Link to comment https://forums.phpfreaks.com/topic/31007-solved-strtotime-difference-between-2-timestamps/#findComment-143082 Share on other sites More sharing options...
cell Posted December 17, 2006 Author Share Posted December 17, 2006 thanks A LOT!works fine for me! ;) Link to comment https://forums.phpfreaks.com/topic/31007-solved-strtotime-difference-between-2-timestamps/#findComment-143085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.