PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

How can I convert 08 to integer in PHP?

Asked 2010-03-07 05:25:02 by Em-Em

I need to compute the difference between two times... example, I have two data from my database, time1 = 08:00:00 and time2 = 17:00 and I need to get hour1 = 08: minute1 = 00, and second1:00... my issue is i need to convert 08 to integer 8 so that there will be no problem with my computation... any help is highy appreciated... thanks...

Anwered 2010-03-07 08:05:28 by Girish M

See the idate function - http://www.php.net/manual/en/function.idate.php

// First convert your time1 into a proper format using 'strtotime' function
$time1_date = strtotime('08:00:00');
// Then get the hour out of it
$time1_hour = idate('h', $time1_date);

Now $time1_hour should be integer 8 for you.

Questions and answers provided by the Yahoo Answers Community.