Re: subtracting time from date and time

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

 



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

       $year = substr($date, 0, 4);
       $mon = substr($date, 4, 2);
       $day = substr($date, 6,2);
       echo "$year - $mon - $day\n";

       $h = substr($time, 0, 2);
       $m = substr($time, 2, 2);
       $s = substr($time, 4,2);
       echo "$h : $m: $s\n";

       $ts = mktime($h,$m,$s,$mon,$day,$year);
?>

-Brad

Richard Kurth wrote:
I am trying to figure out what is the most accurate way to find the time
after I subtract 5 min,15 min, 30 min 1 hour 2 hours and 5 hours from a date
and time that is formatted like this 20070617T193500 this is the way it has to be formatted to work in a
vcalendar

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