Roy Barten Posted February 18, 2009 Share Posted February 18, 2009 How can i calculate the difference between 2 dates in hours? I hav the folliwing variables from an array: $val['start']; $val['end']; I need to know how many hours are between this 2 dates. How do i do that? Please help me! Quote Link to comment https://forums.phpfreaks.com/topic/145744-solved-datedifference/ Share on other sites More sharing options...
ILMV Posted February 18, 2009 Share Posted February 18, 2009 Google is your friend <?php $dateDiff = $val['start'] - $val['end']; $fullHours = floor($dateDiff/(60*60)); echo "Differernce is $fullHours hours"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/145744-solved-datedifference/#findComment-765178 Share on other sites More sharing options...
GingerRobot Posted February 18, 2009 Share Posted February 18, 2009 That's assuming those values are in seconds - i.e unix timestamps. Otherwise you'll need to convert. Where does the data come from? Quote Link to comment https://forums.phpfreaks.com/topic/145744-solved-datedifference/#findComment-765191 Share on other sites More sharing options...
PFMaBiSmAd Posted February 18, 2009 Share Posted February 18, 2009 It was already suggested to the OP that to solve this the format of the date needs to be known, but he did not bother to supply that information - http://www.phpfreaks.com/forums/index.php/topic,239201.0.html Quote Link to comment https://forums.phpfreaks.com/topic/145744-solved-datedifference/#findComment-765193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.