RE: [PHP] subtracting time from date and time

From: Date: Mon, 18 Jun 2007 19:11:07 +0000
Subject: RE: [PHP] subtracting time from date and time
Groups: php.general 
Request: Send a blank email to php-general+get-257331@lists.php.net to get a copy of this message
> 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

« previous php.general (#257331) next »