Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

getTime() etc. not working in Acrobat XI - help?

Avatar

Avatar
Validate 1
Level 1
Salster123
Level 1

Like

1 like

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
Salster123
Level 1

Like

1 like

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
Salster123
Level 1

08-06-2016

Hello,

I have been using getTime() to work out the number of days between 2 dates.

//set the variables

var oneDay = 24*60*60*1000;

var firstDate = new Date(from_date.rawValue);

var secondDate = new Date(to_date.rawValue);

//only if the 2 date fields aren't null

if ((from_date.rawValue!=null)&&(to_date.rawValue!=null)){

num_days.rawValue = Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));

}

It has been working well in lots of versions of Adobe Reader (& other PDF readers) but not in Acrobat Reader XI.

I have tested getYear() and getMonth() and they don't work either!.

I'm very confused and wonder whether anyone else has this problem? (Just in Acrobat Reader XI).

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

13-06-2016

Hi,

Are the fields from_date and to_date Date Fields?  If they are then the rawValue will be in the yyyy-mm-dd.  Using the Date constructor to parse a date has always been inconsistent across environments.  I think that Reader DC (which has JavaScript 2.8) handles the yyyy-mm-dd but the earlier versions don't (which expect the dd mmm yyyy format).  This might depend on the locale used as well.  You might be better using the util.scand() method which is more reliable, so;

//set the variables

var oneDay = 24*60*60*1000;

var firstDate = new Date(util.scand("yyyy-mm-dd", from_date.rawValue).setHours(0,0,0,0));

var secondDate = new Date(util.scand("yyyy-mm-dd", to_date.rawValue).setHours(0,0,0,0));

//only if the 2 date fields aren't null

if ((from_date.rawValue!=null)&&(to_date.rawValue!=null)){

    num_days.rawValue
= Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));

}

Regards

Bruce

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
Salster123
Level 1

Like

1 like

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
Salster123
Level 1

Like

1 like

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
Salster123
Level 1

13-06-2016

Wonderful! That makes me so happy - my work around was using FormCalc, then sending the time to hidden fields to use in JavaScript - not ideal as I prefer to use JavaScript. The only issue I have is that this gives me the positive difference, not a negative one. Thinking that might be the Maths.abs though! Thanks again - Sally.