Re: Time to Calculate Time

From: Date: Mon, 08 Jul 2002 15:30:25 +0000
Subject: Re: Time to Calculate Time
Groups: php.general 
Request: Send a blank email to php-general+get-106096@lists.php.net to get a copy of this message
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" <vins@webonline.co.za> To: <php-general@lists.php.net> 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 >

« previous php.general (#106096) next »