Page 1 of 1

Working out how many hours have pasted from 1 time to anther

Posted: Tue Aug 05, 2003 7:21 am
by Darkside
I need a way of working out how many hours have pasted from to diffrents times and data. eg

2003-07-05 12:00:00 PM

till

2003-08-05 16:00:00 PM

From those date i can work out that 28 hours have passed but I need to work this out using php. So i either need an easy way to work out the diff of 2 dates or i need 2 be able to break down the dates into Days and hours so I can count them up but i'm really clueless.

Posted: Tue Aug 05, 2003 7:53 am
by Stoker
use mktime to generate UNIX timestamps, subtract and divide by 60..

Posted: Tue Aug 05, 2003 10:39 am
by Darkside

Code: Select all

$time = mktime();
$timediff = ($time - $userї5]) /60;
$hourspass = $timediff / 60;
echo round($hourspass);
I used that i think its working but I need 2 wait an hour! I tired just eaching $timediff and it seems more like minutes then hours so.
thanks alot tho.

Posted: Tue Aug 05, 2003 10:48 am
by m3rajk
unix timestamps are in seconds since 11/1970 (unix was made shortly after that and figured dates before then don't really need to be cared about)

Posted: Tue Aug 05, 2003 11:53 am
by Stoker
Read the manual on how mktime works, you must convert your stored spacewasting strings to unixtime