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 #172221 is a reply to message #172189] Sat, 05 February 2011 07:53 Go to previous messageGo to previous message
Jim Higgins is currently offline  Jim Higgins
Messages: 20
Registered: November 2010
Karma:
Junior Member
On Thu, 3 Feb 2011 07:59:38 -0800 (PST), PAkerly <pakerly(at)gmail(dot)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


What does this time your users are entering actually represent? If
it's what time they woke up that day then I guess they'll have to
enter it and you'll need to validate the data before accepting it, but
if it's the time the form was submitted, why leave that to the user to
enter? Just insert the time in your form handler.

If that approach meets your needs, then define...

$the_time = date("H:i:s",time());

in your PHP script then let the form handler insert $the_time into
your MySQL table along with the rest of the form data.
[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: Fri Sep 20 09:45:41 GMT 2024

Total time taken to generate the page: 0.03736 seconds