Hello, I was wondering if anyone can help me with a solution to adding a certain number of days to a date form. I'm creating a quote form and I have one field for the date the quote is created, and a little further down the page I have a field that I want to show when the quote will expire, which is +90 days.
I assume this can be done with Javascript but I cannot figure out how.
Any help or direction will be greatly appreciated
Add days to a date
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Add days to a date
Hello Allan,
Something like this should do the trick for you:
The above of course outputs to the command line and as base uses the current date and time. You will need to get your start time from a field and put the new value to a field, but it was just to show you how to work with dates.
The 7 776 000 000 value is 60 x 60 x 24 x 90 x 1000 (so 90 days x 24 hours x 60 minutes x 60 seconds x milliseconds)
Regards,
Stefan
Something like this should do the trick for you:
Code: Select all
var curDate = new Date(); // Gets date object for right now
var newDate = new Date();
newDate.setTime(curDate.getTime() + 7776000000);
var strDate = util.printd("ddd, mmm dd, yyyy", newDate);
console.println(strDate);
The 7 776 000 000 value is 60 x 60 x 24 x 90 x 1000 (so 90 days x 24 hours x 60 minutes x 60 seconds x milliseconds)
Regards,
Stefan
-
- User
- Posts: 2
- Joined: Tue Nov 27, 2018 3:34 am
Re: Add days to a date
Thanks Stefan,
And sorry for the slow reply, I only just saw this now
Cheers
And sorry for the slow reply, I only just saw this now
Cheers
- Will - Tracker Supp
- Site Admin
- Posts: 6815
- Joined: Mon Oct 15, 2012 9:21 pm
- Location: London, UK
- Contact:
Re: Add days to a date
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.
Best regards
Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Thank you.
Best regards
Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com