Re: Time input formatting in PHP-12 hour clock
| From: | Ronan Chilvers | Date: | Fri, 13 Jun 2003 14:43:38 +0000 |
| Subject: | Re: Time input formatting in PHP-12 hour clock | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28599@lists.php.net to get a copy of this message | ||
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