Page 1 of 1
Date/Time Minus -- date(); [SOLVED]
Posted: Fri Jun 16, 2006 11:31 am
by tecktalkcm0391
I have the date as:
Code: Select all
$old_time = date("F n, Y H:i:s");
$more = 4;
How do I make it add $more hours to the $old_time and then compare it to the current time
and if the new time is >= current time, then it returns false, otherwise it returns true.
NOTE: the old_time is comming from a database entry. not date("F n, Y H:i:s");
Posted: Fri Jun 16, 2006 11:40 am
by John Cartwright
Perhaps..
Code: Select all
$more = 4;
$current = date("F n, Y H:i:s", strtotime('+'. $more .' hours', time()));
Re: Date/Time Minus -- date();
Posted: Fri Jun 16, 2006 12:00 pm
by aerodromoi
tecktalkcm0391 wrote:I have the date as:
Code: Select all
$old_time = date("F n, Y H:i:s");
$more = 4;
How do I make it add $more hours to the $old_time and then compare it to the current time
and if the new time is >= current time, then it returns false, otherwise it returns true.
NOTE: the old_time is comming from a database entry. not date("F n, Y H:i:s");
If I recall the function correctly, F means January through December and n (months as well) 1-12. So where's the day?
aerodromoi
Posted: Fri Jun 16, 2006 12:08 pm
by tecktalkcm0391
opps, i'll fix that n to j
opps, i'll fix that n to j
[quote="Jcart"]Perhaps..
Code: Select all
$more = 4;
$current = date("F n, Y H:i:s", strtotime('+'. $more .' hours', time()));
[/quote
Ok, well how would you do it if it was like this for $old_time
Code: Select all
$get_update = mysql_query("SELECT * FROM `update`");
$get = mysql_fetch_array($get_update)
$old_time = $get['OldTime'];
$more = 4;
Posted: Fri Jun 16, 2006 12:18 pm
by aerodromoi
How about:
Code: Select all
<?php
function checktime($dbdate){
$dbtime = strtotime($dbdate)+4*3600;
$ctime = date("U");
return ($dbtime >= $ctime) ? false : true;
}
//$dbdate = "January 01, 1999 02:22:13";
$dbdate = "June 16, 2006 19:07:13";
if(!checktime($dbdate)) {echo "entry less than (or exactly) four hours old";}
else {echo "entry more than four hours old";}
?>
aerodromoi