Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   Date and Time on HTML Form (http://www.programmingforums.org/showthread.php?t=13023)

Druid Apr 19th, 2007 4:56 PM

Date and Time on HTML Form
 
I have a HTML form displayed via PHP. Currently, the user enters the time and date in a textbox but military time may be a bit difficult for some of the users to calculate. I was wondering if there was a display a visual calendar (I've seen a few examples of this in javascript) and a clock that can allow the user to select the date and time instead of just entering in a string that has to be of a proper format. I was trying to avoid a sequence of dropdown boxes, but that's my last resort. A PHP method to do this would be preferred, but I'm beginning to think it will have to be a Javascript deal. Has anyone developed a date/time gui for a web form or know where I can find one?

Booooze Apr 19th, 2007 4:59 PM

It wouldn't make sense to try and do it through PHP, that's not what PHP was meant for. If your trying to get the time they submitted the form, then you should take the current time using PHP once they have submitted the page. Depending on how you are formatting the time, you could use a combo box and put every hour in. If you want to the minute or second, then a miniature clock or formatted box(s) of some kind would be best.

Druid Apr 19th, 2007 5:18 PM

Bummer. The users just enter the time in a format of HH:MM, which 90% of the time would not be the actual time that they will be referring to, but time in the past of a particular event.

I suppose I'll go the combo box route and rebuild the strings on the server side to form the date and time.

Thanks for the info.

PhilBon Apr 19th, 2007 6:43 PM

What you could do is have a form. And then like you were saying, get a JavaScript Calendar/Clock and have them select the time they want. When they click on it, have JavaScript put in the time into the correct input box. You could also tell them "Enter Time As Such: HH:SS A/P" for Am and PM then you just have PHP do a conversion for time. There is already probably a time class in PHP that will change 12-hour time to 24-hour.


All times are GMT -5. The time now is 2:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC