We have a bunch of events, each event has a date field, and a separate time field that has a start and end value. I'm trying to build a module pulls in the next event that hasn't ended yet. Also, if there are more than one events on that day, we need to pull all of them.

My main problem is figuring out how to construct the values that I need to query that time field with, it seems to be stored is a format that I'm not familiar with, e.g. the value 4:30PM is stored as 59400. I can't find any documentation that specifies how to convert that value back and forth.

Any Drupal gurus / php gurus out there know what that conversion is?

Thanks, Neil


1 Answer 1


Think of it as "the number of seconds since the the start of the day". To get the number of hours from that:

59400 / 60 / 60 = 16.5

So 16.5 hours since the start of the day: 16:30, or 4:30PM.

If you're looking to get something meaningful out of '16.5' for display on the front end, the timefield module has a theme function:

$formatted = theme('timefield_formatter', array('time' => $time));

Or if you have the value in the field of an entity object, you could use field_view_field() instead. The theme function has more options, you'd need to scan through the module code to understand what these are and which you might want to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.