Results 1 to 3 of 3

Thread: [RESOLVED] Formatting a date variable using JQuery?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [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,
    Blake

  2. #2
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    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:
    1. 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.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Formatting a date variable using JQuery?

    I just wrote my own function. thanks!
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width