phpcodec Posted August 11, 2008 Share Posted August 11, 2008 Ok first off i have this timestamp "1218489981" and this timestamp "1218493581" which is an hour ahead of the first timestamp how can i show how many hours, minutes and seconds their is in difference between these 2 timestamps for example. Link to comment https://forums.phpfreaks.com/topic/119206-solved-timestamp/ Share on other sites More sharing options...
.josh Posted August 11, 2008 Share Posted August 11, 2008 Time stamps are measured in seconds. So subtract one timestamp from the other and you have the difference in seconds. Then use basic math to figure out. 60s in a min, 60m in an hour, etc... Link to comment https://forums.phpfreaks.com/topic/119206-solved-timestamp/#findComment-613979 Share on other sites More sharing options...
phpcodec Posted August 11, 2008 Author Share Posted August 11, 2008 yes, but i'm still not sure on how to write the code Link to comment https://forums.phpfreaks.com/topic/119206-solved-timestamp/#findComment-613989 Share on other sites More sharing options...
discomatt Posted August 11, 2008 Share Posted August 11, 2008 <?php $stamp1 = 1218489981; $stamp2 = 1218493687; $diff = abs( $stamp1 - $stamp2 ); $hours = 0; $mins = 0; $sec = 0; $hours = floor( $diff/3600 ); $mins = floor( ($diff-$hours*3600)/60 ); $sec = $diff-$hours*3600-$mins*60; echo "$hours:$mins:$sec"; ?> Link to comment https://forums.phpfreaks.com/topic/119206-solved-timestamp/#findComment-613994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.