Click to See Complete Forum and Search --> : Is there a Date Format in JS?


webdev1
08-08-2003, 02:14 PM
Does anyone know if you can format a date in javascript. In cold fusion there is a fcn called DateFormat which is used in the following context: DateFormat(fieldname, 'yyyy-mm-dd'). Can you do anything like this w/js? I need to compare two dates and the dates must get entered in the form in the format of mm/dd/yyyy but js can't seem to tell between two years, it seems to only compare the months and days. I would like to be able to convert the format of the date to compare the two dates but don't know how to do that, or if it can even be done. Any help would be greatly appreciated! THANKS!

Charles
08-08-2003, 02:20 PM
The JavaScript Date Object (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/obj.html#1008512) is a very powerful thing. It's constructor will take a date in a number of different formats and if it is used as a number it will return the number if miliseconds from the dawn of time (1 January 1970).