> I have 2 date string like this > > $t1 = "2001-11-12 17:30:10"; > $t2 = "2001-11-12 17:15:32"; > > I need to substracts the number of seconds from $t2 from $t1
First, convert them to unix time format: <? Function dateTextToUnix($string) { $year = substr($string, 0, 4); $month = substr($string, 5, 2); $day = substr($string, 8, 2); $hours = substr($string, 12, 2); $mins = substr($string, 14, 2); $secs = substr($string, 16, 2); return mktime($hours, $mins, $secs, $month, $day, $year); } ?> So: <? $t1 = "2001-11-12 17:30:10"; $t2 = "2001-11-12 17:15:32"; $t1unix = dateTextToUnix($t1); $t2unix = dateTextToUnix($t2); $secondsdifference = $t2unix - $t1unix; ?> (apologies for stuff that doesn't work, I've coded this in the email and not tested it :)) Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]