thefollower Posted September 23, 2008 Share Posted September 23, 2008 I am having difficulties figuring out how to get this working... the idea is I have a start timestamp and a "length in hours".. like so: Started On | Length (integer) 2008-23-09 21:00:00 | 2 hours What i then trying to do with the "Current time" is figure out if 2 hours have passed or more.. but just wanted to know what do i check against? I initially did this: <?php $GetDate = mysql_query("SELECT TIME_TO_SEC(TIMEDIFF(NOW(), StartedOn)) AS SecondsPassed,Length As Length FROM task") or die(mysql_error()); $row = mysql_fetch_assoc($GetDate); $Time = $row['SecondsPassed']; $Length = $row['Length']; // length in hours $Var = $Length * 60 * 60; // convert length of hours into seconds $SecondsLeft = $Var - $Time; If($SecondsLeft < 1){ Time has passed }Else{ Echo 'you must wait '.($SecondsLeft / 60).' minutes!'; } ?> The result i keep getting is like "you must wait 18,000 minutes!" which isn't correct. Link to comment https://forums.phpfreaks.com/topic/125527-help-with-time/ Share on other sites More sharing options...
discomatt Posted September 23, 2008 Share Posted September 23, 2008 SELECT `column` FROM `table` WHERE HOUR( TIMEDIFF(NOW(), `StartedOn`) ) >= `Length` If no rows are returned, they have to wait longer Link to comment https://forums.phpfreaks.com/topic/125527-help-with-time/#findComment-649055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.