View Full Version : Date help...

01-12-2004, 10:38 PM
I'm using one of the date chooser's available at www.javascriptkit.com, the one from Denis Gritcyuk. I'm new to Javascript and I need to change the date format that is accepted. Here is the algorithm that is currently used, it takes a string and turns it into a date:

var re_date = /^(\d+)\-(\d+)\-(\d+)$/;

I need to have the date in the format of MMddyyyy.

Any help would be greatly appreciated, TIA.

01-12-2004, 11:37 PM

If you want it simple. It doesn't make sure the date written is valid though.

01-13-2004, 12:33 AM
Thanks for you help. I understand how some of the regex works, is there a way to keep the leading zero for the month and/or day?

01-13-2004, 12:48 AM
This one REQUIRES the date to be written using exactly 2 digits for month, 2 digits for date, 4 digits for year. This is a string match. It will return a string, exactly as it looked in the original. So, it already preserves the leading zeroes.

01-13-2004, 05:27 PM
Its working perfectly now. I had a problem with the Date constructor...I had to put the RegEx.1,2,and 3 in the right order.

Thanks for you help.