Add days to a date

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
allan@powerglide.co.nz
User
Posts: 2
Joined: Tue Nov 27, 2018 3:34 am

Add days to a date

Post by allan@powerglide.co.nz »

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 :)
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17948
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add days to a date

Post by Tracker Supp-Stefan »

Hello Allan,

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 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
allan@powerglide.co.nz
User
Posts: 2
Joined: Tue Nov 27, 2018 3:34 am

Re: Add days to a date

Post by allan@powerglide.co.nz »

Thanks Stefan,

And sorry for the slow reply, I only just saw this now :(

Cheers
User avatar
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

Post by Will - Tracker Supp »

:D
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
Post Reply