Separating Dates & Times
2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 21, 2010 (RSS)
By Perchpole - June 21, 2010
Hello, All -
I recently ran into an issue with the way CMSB handles the input of dates and times. My client would prefer a much simpler system but it seems I am unable to create it for him.
Currently you can set up CMSB to handle dates using a predefined set of drop-down menus. You also have the option of adding the time. However, what you can't do is add the time without first adding a date!
To solve my problem I would like a way of adding a time which is entirely separate from the date.
I'll save you the details of why this feature is important. Suffice it to say, the client in question is working with lots of time slots on the same day. For each slot he needs to input a start and a finish time. As things stand, whenever he adds a time he's also compelled to add the date. This seems needlessly repetitive - not to say confusing (for the client).
I have considered creating my own drop-down menus listing all the available start times (for example) as: 8:00, 8:15, 8:30, etc. The only trouble is I'm not entirely sure how to convert these strings/numbers into real PHP values for use in other lists/calculations.
Any help or suggestions would be most welcome.
:0)
Perch
I recently ran into an issue with the way CMSB handles the input of dates and times. My client would prefer a much simpler system but it seems I am unable to create it for him.
Currently you can set up CMSB to handle dates using a predefined set of drop-down menus. You also have the option of adding the time. However, what you can't do is add the time without first adding a date!
To solve my problem I would like a way of adding a time which is entirely separate from the date.
I'll save you the details of why this feature is important. Suffice it to say, the client in question is working with lots of time slots on the same day. For each slot he needs to input a start and a finish time. As things stand, whenever he adds a time he's also compelled to add the date. This seems needlessly repetitive - not to say confusing (for the client).
I have considered creating my own drop-down menus listing all the available start times (for example) as: 8:00, 8:15, 8:30, etc. The only trouble is I'm not entirely sure how to convert these strings/numbers into real PHP values for use in other lists/calculations.
Any help or suggestions would be most welcome.
:0)
Perch
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:
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:
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.
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/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/