Does anyone know how can I get next week date based on this week date? example if I have this thursday date (25/6/2009) how can I use javascript to get next thursday date (2/7/2009)?
Using setDate() passing the result of <today>. getDate() + 1 , you'll set the day as “tomorrow”.
var today = new Date(); var startDay = 0; var weekStart = new Date(today. getDate() - (7 + today. getDay() - startDay) % 7); var weekEnd = new Date(today. getDate() + (7 - today.
To get last week's date, use the Date() constructor to create a new date, passing it the year, month and the day of the month - 7 to get the date of a week ago. Copied! function getLastWeeksDate() { const now = new Date(); return new Date(now. getFullYear(), now.
var firstDay = new Date("2009/06/25"); var nextWeek = new Date(firstDay.getTime() + 7 * 24 * 60 * 60 * 1000);
You can also look at DateJS if you like "fluent" APIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With