Page 1 of 1

convert time field to individual integers

Posted: Thu Nov 13, 2003 5:05 am
by jolan_lars
hi,

i have a mysql TIME field in the format hh:mm:ss

How do I separate each value of hours, mins and secs and present them as integers so that i can make the proper calculations in PHP.

I tried strftime, strtotime, mktime but i cant make it work.

Please help.

Posted: Thu Nov 13, 2003 5:51 am
by twigletmac
You can just [php_man]explode[/php_man]() the value:

Code: Select all

$time_bits = explode(':', $time_from_db);
Although depending what you are trying to do you may be able to get MySQL to do most of the work not PHP.

Mac