What's wrong with this script?
When I set my clock to say 29/04/2011 it adds 36/4/2011 in the week input! but the correct date should be 6/5/2011
var d = new Date(); var curr_date = d.getDate(); var tomo_date = d.getDate()+1; var seven_date = d.getDate()+7; var curr_month = d.getMonth(); curr_month++; var curr_year = d.getFullYear(); var tomorrowsDate =(tomo_date + "/" + curr_month + "/" + curr_year); var weekDate =(seven_date + "/" + curr_month + "/" + curr_year); { jQuery("input[id*='tomorrow']").val(tomorrowsDate); jQuery("input[id*='week']").val(weekDate); }
Just do: $date = strtotime("+7 day"); echo date('M d, Y', $date);
getDay() The getDay() method returns the day of the week for the specified date according to local time, where 0 represents Sunday.
var date = new Date(); date.setDate(date.getDate() + 7); console.log(date);
And yes, this also works if date.getDate() + 7
is greater than the last day of the month. See MDN for more information.
Without declaration
To return timestamp
new Date().setDate(new Date().getDate() + 7)
To return date
new Date(new Date().setDate(new Date().getDate() + 7))
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