The getDate returns an actual date object that you will need to format. There is a utility function as part of the datepicker that will format an actual date object into a string based on a format string that you provide.
http://docs.jquery.com/UI/Datepicker/formatDate So, this should get you what you want... var dateText = $.datepicker.formatDate("yy-mm-dd",$ ("#datepicker").datepicker("getDate")); Hth, Dave On Oct 20, 5:13 pm, "alfrod...@gmail.com" <alfrod...@gmail.com> wrote: > I am trying to get the currently selected date in YYYY-MM-DD format > and am having problems. If I get the date via the onSelect function I > passed as an option when initializing the object, the date is returned > correctly. > > Here's how I create it: > > $(function() { > $("#datepicker").datepicker({changeMonth: true, changeYear: > true, > onSelect: function(dateText, inst){dateSelectFunc(dateText);}, > dateFormat: 'yy-mm-dd'}); > > }); > > function dateSelectFunc(dateText, inst) > { > alert("you picked " + dateText); > > } > > The alert box shows the day as 2009-10-14. > > But if I have code that uses the getDate method, it returns the date > as: > Wed Oct 14 2009 00:00:00 GMT-0500 (Central Daylight Time) > > I even specifically reset the dateFormat before I call getDate: > > $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'}); > var dateText = $("#datepicker").datepicker('getDate'); > alert(dateText); > > That alert gives me Wed Oct 14 2009 00:00:00 GMT-0500 (Central > Daylight Time). > > What I am trying to do is to refresh a list of events on a specific > date after a person has deleted one or edited it. A person clicks on > a date in the datepicker and that calls $("#eventlistings").load() and > loads a list of events with a delete option next to each one. When > the user deletes a date, I want to re-get all of the events on the > select date to show them that the event was deleted. So I am trying > to use the dateText variable. dateText needs to be 2009-10-14, but > I'm getting the long version. > > I'm having a bad day, so I know I'm doing something stupid. I just > can't figure out what. :) > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to jquery-ui@googlegroups.com To unsubscribe from this group, send email to jquery-ui+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~---