Reputation: 450
I am using a dropdownlist and a calendar control in my page. In that I am having following list items. 1)Last Week 2)last month
If I choose last week in the dropdownlist the calendar control should display the date range from date 7 days ago and today's date. How can I get it through Java Script
Upvotes: 0
Views: 3876
Reputation: 123791
How about using DateJS library?
Its return
Upvotes: 0
Reputation: 187020
var curDate = new Date();
var prevDate = new Date();
prevDate.setDate ( curDate.getDate() - 7 );
Upvotes: 1
Reputation: 70414
// current date
var now = new Date();
// 7 days earlier
now.setDate(now.getDate()-7);
Upvotes: 11