Convert Date time into Seconds

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

 



Good Day,

I'm chech if 24hrs has passed between these 2 datetimes:

$dTime1 = 2007-06-21 11:08:09;

$dTime2 = 2007-06-22 07:08:09;

I'd really like to convert the datetimes above into a format I can do 
regular math them.

Browsing around I've found the following code.  But both weren't clear on 
what to pass to them.  Because when I pass a datetime var to them and echo 
the value I get no output please help.
======================================================================
function datetime_to_epoch($date)
{
  $break = explode(" ", $date);
  $datebreak = explode("-", $break[0]);
  $time = explode(":", $break[1]);
  $epoch = date("U", 
mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0]));
  $datetime = date("Y-m-d H:i:s", 
mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0]));
}
?>
=======================================================================
function convert_datetime($varStamp) {

    list($date, $time) = explode(' ', $str);
    list($year, $month, $day) = explode('-', $date);
    list($hour, $minute, $second) = explode(':', $time);

    $timestamp = mktime($hour, $minute, $second, $month, $day, $year);

    return $timestamp;
}

//If anyone could elaborate, would be appreciated.
================================================================================ 

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