I use this to get the date:
var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() alert(month + "/" + day + "/" + year);
How can I add 2 weeks ? So instead of showing 10/13/2011, to show 10/27/2011 etc
Here is the fiddle: http://jsfiddle.net/25wNa/
I want the one input to have +14 days and the other +21
Note: I'd like the format to be > 10/13/2011 <.
function addWeeks(numOfWeeks, date = new Date()) { date. setDate(date. getDate() + numOfWeeks * 7); return date; } // Add 2 weeks to current Date console.
This is the Smallest and easiest code. var minDate = new Date(); minDate. setMonth(minDate. getMonth() - 3);
12096e5
is a magic number which is 14 days in milliseconds.
var fortnightAway = new Date(Date.now() + 12096e5);
jsFiddle.
var currentTime = new Date(); currentTime.setDate(currentTime.getDate()+14);
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