Date and Time Help

ronh100

I have a text input form box that has a date time javascript snippet in it to forward date and time of registration when customer hits submit button. When the date time shows up in the database it sometimes is spelled out (Monday March 23, 2013 3:15 pm) and sometimes is only numbers (3/23/2013 3:15 pm). I would be grateful for help to make the script always show the numbers only (3/23/2013 3:15 pm) and not the spelled out version. How do you apply a css to the javascript to change the font size and color? The code is below. Thank you.

ronh100

Thank you JMRKER for the prompt response. This works great but I need it to appear inside a form text box so my php script can grab the box value and put it into my database. Can you give me the html code to make this script result appear in a HTML form input text box when the page opens? Sorry, I'm a newbie and need to walked around by the hand.

JMRKER

As a newbie, you should at least attempt a change. If it works, you learn something.
If it doesn't work, you show your attempt and you learn from our suggested changes.

I'm bypassing my own advice this time, but in the future, at least try something...

ronh100

I have actually been searching the Internet for the answer for a couple of days before I left this thread. I experimented with script I found on about 20 pages but I couldn't get anything to work exactly the way I wanted. Mixing text areas, databases and Javascript isn't the easiest thing to do for a newbie. I thank you for your help but I don't think you should assume that I haven't tried to figure it out myself. Thanks again. I appreciate your response. This is exactly what I needed.

ronh100

Can you please adjust the code so the "0" shows up before the minute number when it is less than 10. I am getting "3/22/2013 7:4 pm" on the display now. Thank you.

JMRKER

ronh100;1257247 wrote:

Can you please adjust the code so the "0" shows up before the minute number when it is less than 10. I am getting "3/22/2013 7:4 pm" on the display now. Thank you.

But that is exactly what you asked for in post #1.
Have the requirements changed?
Also, do you need to modify the date (/22/) if it is also less than 10?

See if you can write the simple function to do this. It's pretty easy.
At least make an attempt!

ronh100

I got code parts from other web sites and cobbled together a script that actually works but I don't know if it is good code or not. Would you look at my code and let me know if it is good code?

root

Also, please don't use setTimeout repeatedly to update your clock, use setInterval as it only needs setting once. If you look in to it, you have an overhead with setTimeout, although it may be in some eyes a minor point and a small price to pay, in the realms of utilizing script processing and accuracy, repeated calls of setTimeout has an overhead that does eventually build up.