Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  2] [ 1]  / answers: 1 / hits: 83406  / 13 Years ago, thu, october 13, 2011, 12:00:00

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 <.


More From » date

 Answers
61

12096e5 is a magic number which is 14 days in milliseconds.



var fortnightAway = new Date(Date.now() + 12096e5);


jsFiddle.


[#89637] Wednesday, October 12, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
danalexc

Total Points: 114
Total Questions: 119
Total Answers: 103

Location: Hungary
Member since Wed, Nov 9, 2022
2 Years ago
;