P
Paul E. Schoen
I am using a JavaScript in a NitroPro PDF application, and I want to be
able to set a date that is a certain number of days ahead or prior to the
present date. I found the conversions from/to UNIX date format in
http://www.merlyn.demon.co.uk/js-date1.htm#CtDC but my script seems to work
a bit strangely:
var sPrompt = app.response("Enter days offset");
var d = new Date();
var tbText = this.getField("Text2_101"); //doc.fieldName
var UnixDays =Math.floor(d/864e5) + sPrompt;
var d1 = new Date((UnixDays)*864e5);
tbText.value = d1.getMonth()+"/"+d1.getDate()+"/"+(d1.getYear()+1900-355);
With an offset of zero(0), this gives 5/23/2009 with today's date of
6/13/2009.
An offset of one (1) gives 5/24/2009, but a negative offset of (-1) gives
NaN/NaN/NaN.
An offset of 9 gives 6/2/2009, but 10 gives 9/21/5559.
An offset of 23 gives a date of 10/3/5559.
I also don't know why I had to subtract 355 years from the getYear()
function.
Is there something wrong in the scripting implementation of NitroPro?
Thanks,
Paul
able to set a date that is a certain number of days ahead or prior to the
present date. I found the conversions from/to UNIX date format in
http://www.merlyn.demon.co.uk/js-date1.htm#CtDC but my script seems to work
a bit strangely:
var sPrompt = app.response("Enter days offset");
var d = new Date();
var tbText = this.getField("Text2_101"); //doc.fieldName
var UnixDays =Math.floor(d/864e5) + sPrompt;
var d1 = new Date((UnixDays)*864e5);
tbText.value = d1.getMonth()+"/"+d1.getDate()+"/"+(d1.getYear()+1900-355);
With an offset of zero(0), this gives 5/23/2009 with today's date of
6/13/2009.
An offset of one (1) gives 5/24/2009, but a negative offset of (-1) gives
NaN/NaN/NaN.
An offset of 9 gives 6/2/2009, but 10 gives 9/21/5559.
An offset of 23 gives a date of 10/3/5559.
I also don't know why I had to subtract 355 years from the getYear()
function.
Is there something wrong in the scripting implementation of NitroPro?
Thanks,
Paul