You are right I was looking at it as 0735 was in the morning sorry about that. In that case it works perfect > -----Original Message----- > From: Jim Lucas [mailto:lists@xxxxxxxxx] > Sent: Monday, June 18, 2007 12:21 PM > To: Richard Kurth > Cc: php-general@xxxxxxxxxxxxx > Subject: Re: subtracting time from date and time > > Richard Kurth wrote: > > > > > >> -----Original Message----- > >> From: Chris Boget [mailto:chris.boget@xxxxxxxx] > >> Sent: Monday, June 18, 2007 10:55 AM > >> To: Brad Bonkoski; Richard Kurth > >> Cc: php-general@xxxxxxxxxxxxx > >> Subject: Re: subtracting time from date and time > >> > >>> Something like this will get it into a time stamp...and > >> then you can > >>> do your calculations with ease, and reformat... > >>> <?php > >>> $str = "20070617T193500"; > >>> list($date, $time) = explode("T",$str); ?> > >> Even easier: > >> > >> $timestamp = strtotime( $str ); > >> http://us2.php.net/manual/en/function.strtotime.php > >> > >> $oneMinute = 60; // seconds > >> $oneHour = $oneMinute * 60; > >> $oneDay = $oneHour * 24; > >> > >> echo '5 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( > >> $oneMinute * > >> 5 )); > >> echo '5 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( > $oneHour * > >> 5 )); echo '5 days ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( > >> $oneDay * 5 )); > > > > 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 > > > > $str = "20070617T193500"; > > Notice that this time stamp is formatted in 24/hr days. > > so > year 2007 > month 6 > day 17 > > hour 19 = 7pm (not 7am) > minute 15 > second 00 > > > > $timestamp = strtotime( $str ); > > $oneMinute = 60; // seconds > > $oneHour = $oneMinute * 60; > > $oneDay = $oneHour * 24; > > echo 'time: ' . date( 'm/d/Y h:i:s', $timestamp ); > echo"<br>"; echo '5 > > minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( > $oneMinute *5 )); > > echo"<br>"; echo '15 minutes ago: ' . date( 'm/d/Y h:i:s', > $timestamp > > - ( $oneMinute *15 )); echo"<br>"; echo '30 minutes ago: ' . date( > > 'm/d/Y h:i:s', $timestamp - ( $oneMinute *30 )); > echo"<br>"; echo '1 > > hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * 1 )); > > echo"<br>"; echo '2 hours ago: ' . date( 'm/d/Y h:i:s', > $timestamp - ( > > $oneHour * 2 )); echo"<br>"; echo '5 hours ago: ' . date( 'm/d/Y > > h:i:s', $timestamp - ( $oneHour * 5 )); echo"<br>"; echo '7 hours > > ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * 7 )); > > echo"<br>"; echo '8 hours ago: ' . date( 'm/d/Y h:i:s', > $timestamp - ( > > $oneHour * 8)); > > > > > -- > Jim Lucas > > "Some men are born to greatness, some achieve greatness, > and some have greatness thrust upon them." > > Twelfth Night, Act II, Scene V > by William Shakespeare > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php