Re: Time input formatting in PHP-12 hour clock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi David

Comments inline...

On 13 Jun,2003 at 10:26 David Shugarts wrote:

<snip>
> PHP--I need the user to be able to input a time, then validate it as to
> whether it is complete (e.g., expresses AM or PM and evaluates correctly),
> then pass it into an INSERT statement into the time field of a database.
> 
</snip>

How about using a radio button for the AM / PM selection on the form? Then if its PM you can simply adjust the hour figure accordingly to convert to 24hr (add 12 or whatever) and then concatenate a string together for the INSERT, eg: HHMMSS.

Validating is just a matter of making sure the numbers are sane....a few if then's should do the trick.  Alternatively use select dropdowns on the form to only allow a user to choose a valid time.  Its up to them to get the RIGHT time, of course !!!  If you go the validation route I think I would probably use a little javascript snippet to validate the numbers before the form is submitted.  Personal preference really...

Does this help at all?

Ronan
e: ronan@thelittledot.com
t: 01903 739 997
w: www.thelittledot.com

The Little Dot is a partnership of
Ronan Chilvers and Giles Webberley

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux