SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2010
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to format the date in jQuery datepicker

    I'm new to Javascript so this might be a real easy fix. But I'm trying to figure out a way to reformat the date that jQuery's datepicker pulls up. I want it formatted to yyyy-mm-dd so I can move it with PHP into my MySQL database. This seems like it will be the easiest way, there's even a couple of bits within the jQuery website about how to do this. They provide a code, but I can't figure out how or where to apply the code. I've tried both within and just underneath the call script on the page, but nothing.

    Here's one of the codes that I've found listed over the web:

    HTML Code:
    $("selector).datepick({dateFormat: 'DD, MM d, yyyy', altField: '#isoDate', altFormat: 'yyyy-mm-dd'});
    This is what jQuery's site has listed:
    HTML Code:
    $.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26));
    Am I missing something here?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    The format date example in the jQuery UI documentation might be useful for you here, and for further details on how to handle the dateFormat part, open up the Options tab below the demo and click on dateFormat
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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