RE: subtracting time from date and time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> This works great tell you get to 8 hours ago 
> it shows the correct time but it does not change 
> the date to the day before. 8 hours ago should be
> 06/16/2007 11:35:00 but what it shows is 06/17/2007 
> 11:35:00

Your code works for me.  Though, I had to change the format of $str
slightly to get it to work on a windows box.  Additionally, I tried the
following (which also worked):

<?
  $str = "2007-06-17T19:35:00";
  $timestamp = strtotime( $str );

  $oneMinute = 60; // seconds
  $oneHour   = $oneMinute * 60;
  $oneDay    = $oneHour * 24;

  for( $i = 1; $i <= 24; $i++ ) {
    echo $i . ' hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - (
$oneHour * $i )) . '<br>';

  }
?>

thnx,
Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux