![]() ![]() So next time, while using setDate() method remember these little but useful things.įeel free to contact me for any help related to jQuery, I will gladly help you. 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') Use datepicker API to set date to a different date using setDate function. (.date-pick).datepicker() (.date-pick).datepicker(setDate. Using the UI, select datepicker then select a date. You can also pass this in weeks, month, years or combination of any of these. You must FIRST call datepicker() > then use setDate to get the current date. 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. You must FIRST call datepicker () > then use 'setDate' to get the current date. If a date is chosen, feedback is shown as the input's value. ![]() Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. $('#txtDate').datepicker().datepicker('setDate', new Date()) Date: The datepicker is tied to a standard form input field. Approach: First, add jQuery mobile scripts needed for your project. Return values: This method returns the date. Syntax: ( '.selector' ).datepicker ( 'setDate' ) Parameters: This method does not accept any parameters. SetDate() method takes 'date' as argument but this argument either can be date object or string object. 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. Earlier today, I posted about " How to Set Current Date in jQuery UI Datepicker" using setDate() method provided by jQuery UI Datepicker library. ![]()
0 Comments
Leave a Reply. |