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 ));

etc., etc., etc.

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

Reply via email to