



Use "y" for years, "m" for months, "w" for weeks, "d" for days.įor 1 month from current date, $('#txtDate').datepicker().datepicker('setDate', '+1m') įor 1 year from current date, $('#txtDate').datepicker().datepicker('setDate', '+1y') įor 1 month and 7 days from current date, $('#txtDate').datepicker().datepicker('setDate', '+1m +7d') You can also pass this in weeks, month, years or combination of any of these. Javascript date setDate() method sets the day of the month for a specified date according to local time. This code will set the date as " 1", considering today is " ". Consider below jQuery code, $('#txtDate').datepicker().datepicker('setDate', '+7') $('#txtDate').datepicker().datepicker('setDate', '') īut you can also pass number of days from today which you want to set as date. The new date may be a Date object or a string in the current date format (e.g., ''), a number of days from today (e.g., +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g., '+1m +7d'), or null to clear the selected date. $('#txtDate').datepicker().datepicker('setDate', new Date()) setDate ( date ) Sets the date for the datepicker. SetDate() method takes 'date' as argument but this argument either can be date object or string object. Syntax: ( '.selector' ).datepicker( 'setDate' ) Parameters: This method does not accept any parameters. Parameter: This method accept a single parameter as mentioned above and described below: dateValue: It returns the new i.e updated date of the month which is set by setDate () method. jQuery UI datepicker setDate() method is used to set the date from the date field. But there are few interesting things which you can also do with setDate() method which you might not be knowing. The tDate () method is used to set date of a month into a date object which are created using date () constructor.
#Setdate jquery how to
Earlier today, I posted about " How to Set Current Date in jQuery UI Datepicker" using setDate() method provided by jQuery UI Datepicker library.
