Separating Dates & Times

2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 21, 2010   (RSS)

Re: [Perchpole] Separating Dates & Times

By Jason - June 21, 2010

Hi Perch,

It sounds like your idea of having your own drop down list would be the best solution.

All the date value returned from the database come back as strings, so we can convert them to a time format that the server can manipulate like this:

$time = strtotime($record['time']);

This converts what was stored in the database to a unix time stamp. If we need to turn it back to a string value that it's easy to read, we can try something like this:

$stringTime = date("g:i a",$time);
This would format the time to read hour:minutes am/pm
ex.
8:30 pm

Note, if you don't specify am/pm in your date list, it will assume am. You can also use 24 hour formats with this.

For more options for formatting using the date() function, take a look here:
http://php.net/manual/en/function.date.php

Hope this helps. Let me know if you run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/