|
-
Mar 26th, 2013, 10:57 AM
#1
Thread Starter
PowerPoster
[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,
-
Mar 26th, 2013, 05:25 PM
#2
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.
-
Mar 26th, 2013, 05:38 PM
#3
Thread Starter
PowerPoster
Re: Formatting a date variable using JQuery?
I just wrote my own function. thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|