javascript - Formating Date so MySQL will accept it -



javascript - Formating Date so MySQL will accept it -

i writing page take info user , submitted form. wanted date included in form info wrote little snippet insert current date when form submitted:

<li> <input type="hidden" id="date" name="date_val" value="date"> <script type="text/javascript"> document.getelementbyid('date').value = date(); </script> </li>

now when print out form nonsense date 11--00-01 printed in table. looking @ _post info getting sent mysql:

array ( [formid] => 42796558181164 [date_val] => wed oct 22 2014 17:50:43 gmt-0400 (eastern standard time) etc...

i'm assuming why gibberish output. have mysql object defined simple date format. can tell me how should format date mysql take , output correctly?

thanks...

answer:

<li> <input type="hidden" id="date" name="date_val" value="date"> <script src="jscripts/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> date_tda = new date().toisostring().slice(0, 19).replace('t', ' '); document.getelementbyid('date').value = date_tda; </script> </li>

answer:

<li> <input type="hidden" id="date" name="date_val" value="date"> <script src="jscripts/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> date_tda = new date().toisostring().slice(0, 19).replace('t', ' '); document.getelementbyid('date').value = date_tda; </script> </li>

javascript

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -