Try this: <?php
function unixTime($time) { $year=substr($time,0,4); $month=substr($time,4,2); $day=substr($time,6,2); $hour=substr($time,8,2); $min=substr($time,10,2); $sec=substr($time,12,2); return strtotime("$year/$month/$day $hour:$min:$sec"); } $time1='20020707140000'; $time2='20020707160000'; $timeDiff=unixTime($time2)-unixTime($time1); echo "The two times are $timeDiff seconds apart"; ?> There's bound to be a way to do this much more neatly using a regexp but this was quick to write and it works :) HTH Danny. ----- Original Message ----- From: "vins" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, July 08, 2002 4:02 PM Subject: [PHP] Time to Calculate Time > Hey there ppl.. > > One dam thing i've been trying to figure out for about 2 weeks now it how > the hell to calculate time. > > i have variables $Start, $End each with a timestamp 2 hours apart > (20020707140000, 20020707160000) respectively.... > > How do i calculate those to timestamps to get the answer 2????? > > I've tried working them into unix timestamps and then calculating but no > luck... > > any one got any ideas ?? > > Thanx > Vins > > > > -- > 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