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 #172222 is a reply to message #172189] Sat, 05 February 2011 08:11 Go to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma:
Member
"PAkerly" wrote in message
news:cc56a3eb-87fe-4d5f-bd8e-23c19238abfa(at)g1g2000prb(dot)googlegroups(dot)com...

> I've got a form where users enter in time into a textbox.
> txttime1
> txttime2

You could use a date/time picker where the user selects a date from a
calendar and the time can be adjusted with spin controls. See an example at:
http://www.pauleschoen.com/SCGBG/EventSubmit.htm

There is a text box where the user can also directly edit it but I use a
simple Javascript format checker in case they screw up:

else if ( (Form1.Start_DT.value.charAt(2) != "/") ||
(Form1.Start_DT.value.charAt(5) != "/") ||
(Form1.Start_DT.value.charAt(10) != " ") ||
(Form1.Start_DT.value.charAt(13) != ":") )
{
alert ("Please use mm/dd/yyyy hh:mm Format for Date/Time");
Form1.Start_DT.focus();
}
else { //Everything seems OK
with (Form1.Start_DT) { //Update hidden variable to be sent
Form1.Entry_Start_DT.value =
value.substring(6,10) + "-" +
value.substring(0,2) + "-" +
value.substring(3,5) + "T" +
value.substring(11,13) + ":" +
value.substring(14,16);
}

Not the best, but it works. Note that I format the date in standard format:
yyyymmddThh:mm

I might use some of the other ideas submitted here.

Thanks,

Paul
[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: Wed Nov 27 10:05:18 GMT 2024

Total time taken to generate the page: 0.04185 seconds