convert time field to individual integers

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jolan_lars
Forum Newbie
Posts: 19
Joined: Thu Oct 23, 2003 12:15 pm

convert time field to individual integers

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply