Reputation: 1726
I am using one jquery date picker,
with using picker i am getting date in like this format
Friday, May 21, 2010
Now i want to add one day in this date so i think, i can only do if i change the date in exact format like 21/5/2010
I want to only convert that bcz i want to add one day to the particular date.
So what do u suggest me? How can I do that?
Can i do without converting it ?
thanks in advance....
Upvotes: 1
Views: 5142
Reputation: 146460
The date format has nothing to do with how dates are stored; it only affects the way dates are displayed. JavaScript has a native Date object and jQuery UI's Datepicker allows to access such object:
http://jqueryui.com/demos/datepicker/#method-getDate
Once you have a Date object, you can alter it to suit your needs:
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date
Finally, you can feed it back into Datepicker:
http://jqueryui.com/demos/datepicker/#method-setDate
Upvotes: 0
Reputation: 1069
I think you need to detail what jQuery plugin do you use. Is it this one? http://jqueryui.com/demos/datepicker/
If so, then when you cann getDate
method, you'll get Date
object representing a date. You can easily manipulate it.
Upvotes: 0
Reputation: 19368
In addition to the formatting options given by others, you should add using date objects rather than to the string representation of the date object.
I.E.
// add 5 days to today
var myDate=new Date();
myDate.setDate(myDate.getDate()+5);
Upvotes: 0
Reputation: 18175
Take a look at http://docs.jquery.com/UI/Datepicker#option-dateFormat
Upvotes: 2