Hatcher
07-27-2003, 04:31 PM
The scvript below is a function that accepts in a datetime, picks it apart and computes the number of hours between that datetime and the current datetime, now() at the moment the script is running.
The new function I need is the reverse of this. It should take in a number of hours X, and compute and return a datetime that is X hours from the current time (now) at the moment the script is running.
php:
--------------------------------------------------------------------------------
<?php
//this is a precise time interval between 2 different times.
function getIntervalTime($t1) {
if ($t1 == 0) return -1;
$lastYear = substr($t1, 0, 4);
$lastMonth = substr($t1, 5, 2);
$lastDay = substr($t1, 8, 2);
$lastHour = substr($t1, 11, 2);
$lastMinute = substr($t1, 14, 2);
$lastSecond = substr($t1, 17, 2);
$lastUpdateTime = mktime($lastHour, $lastMinute, $lastSecond, $lastMonth, $lastDay, $lastYear);
$now = getdate();
$nowTime = mktime($now['hours'],$now['minutes'],$now['seconds'],$now['mon'],$now['mday'],$now['year']);
$diff = floor(($nowTime - $lastUpdateTime)/3600); // in hours
return $diff;
}
?>
--------------------------------------------------------------------------------
Would this work if i used:
php:
--------------------------------------------------------------------------------
$add = floor(($nowtime + $diff)/3600);
return $add;
?>
--------------------------------------------------------------------------------
That would be added here:
php:
--------------------------------------------------------------------------------
$diff = floor(($nowTime - $lastUpdateTime)/3600); // in hours
$add = floor(($nowtime + $diff)/3600);
return $add;
}
?>
?>
--------------------------------------------------------------------------------
Please get back to me ASAP.
Thanx In Advance
The new function I need is the reverse of this. It should take in a number of hours X, and compute and return a datetime that is X hours from the current time (now) at the moment the script is running.
php:
--------------------------------------------------------------------------------
<?php
//this is a precise time interval between 2 different times.
function getIntervalTime($t1) {
if ($t1 == 0) return -1;
$lastYear = substr($t1, 0, 4);
$lastMonth = substr($t1, 5, 2);
$lastDay = substr($t1, 8, 2);
$lastHour = substr($t1, 11, 2);
$lastMinute = substr($t1, 14, 2);
$lastSecond = substr($t1, 17, 2);
$lastUpdateTime = mktime($lastHour, $lastMinute, $lastSecond, $lastMonth, $lastDay, $lastYear);
$now = getdate();
$nowTime = mktime($now['hours'],$now['minutes'],$now['seconds'],$now['mon'],$now['mday'],$now['year']);
$diff = floor(($nowTime - $lastUpdateTime)/3600); // in hours
return $diff;
}
?>
--------------------------------------------------------------------------------
Would this work if i used:
php:
--------------------------------------------------------------------------------
$add = floor(($nowtime + $diff)/3600);
return $add;
?>
--------------------------------------------------------------------------------
That would be added here:
php:
--------------------------------------------------------------------------------
$diff = floor(($nowTime - $lastUpdateTime)/3600); // in hours
$add = floor(($nowtime + $diff)/3600);
return $add;
}
?>
?>
--------------------------------------------------------------------------------
Please get back to me ASAP.
Thanx In Advance
