FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » validating / converting time for insertion into mysql DB??
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: validating / converting time for insertion into mysql DB?? [message #172190 is a reply to message #172189] Thu, 03 February 2011 17:32 Go to previous messageGo to previous message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma:
Senior Member
On Feb 3, 3:59 pm, PAkerly <pake...@gmail.com> wrote:
> I've got a form where users enter in time into a textbox.
> txttime1
> txttime2
>
> usually for 12:15 the user enters 1215 without the :, so basically the
> user does not enter :
>
> and in the db the time goes into the db as: 00:12:15 instead of
> 12:15:00
>
> So what I want to do is somehow fix the time so that when a user
> enters it as 1215, it changes the time to 12:15
>
> so than the $_POST[txttime1] would be correct at 12:15 and not 1215
>
> How would this be done?
> TIA

Well first of all you need to decide on how you are going to interpret
what the user has entered.
was 120 supposed to be 01:20 or 12:00?

Suppose they enter 1h22, what do you plan to do then?

What you SHOULD do, is to validate that they have entered something in
a valid format and if not, send them an error message and ask them to
correct it.

Alternatively, split the boxes and have hours in one box and minutes
in another.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: pass variable in php construct
Next Topic: Looping through Web Service results
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 17:18:13 GMT 2024

Total time taken to generate the page: 0.10316 seconds