Jump to content

Help with time


thefollower

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.