[RESOLVED] Formatting a date variable using JQuery?
Is there a way to format a date value in JQuery? I have a variable that contains a date value in this format: Tue Mar 19 2013 00:00:00 GMT-0800 (Pacific Standard Time). I need it to be in "mm/dd/yyyy" format? I have been searching the web and can't really find anything. I can use regular javascript too.
Thanks,
Re: Formatting a date variable using JQuery?
You can just parse that string into the standard Date object in JavaScript via it's constructor.
JavaScript Code:
new Date('Tue Mar 19 2013 00:00:00 GMT-0800 (Pacific Standard Time)');
If you're using jQuery UI then you can use the Datepicker Widget to format your date output using the formatDate utility method.
Otherwise, it's probably easiest to just use the methods on the Date object: getDate, getMonth, and getFullYear for local time, or their UTC equivalents.
Re: Formatting a date variable using JQuery?
I just wrote my own function. thanks!