longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

Shortcut for "This week" "This month" #497

Closed balogatt closed 3 years ago

balogatt commented 3 years ago

Hi!

Like this shortcuts This week or This month would be great. or How to make this with customShortcuts section?

balogatt commented 3 years ago

Ok, I find a solution: { name: '| This Week ', dates : function() { var start = moment().day(1).toDate(); var end = moment().day(7).toDate(); return [start,end]; } }, { name: '| This Month ', dates : function() { var start = moment().startOf('month').toDate(); var end = moment().endOf('month').toDate(); return [start,end]; } },

monovertex commented 3 years ago

You can also see more examples for the custom shortcuts here. I will close this issue as it is resolved, feel free to reply to this thread if you have further questions regarding the usage of shortcuts.