Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Working with date and time in acrobat JavaScript help request...

$
0
0

This came from

Working with date and time in Acrobat JavaScript (Part 1 of 3)

The following code adds five days to the current date and then prints the new date to the console window.

 

// Get the current date and time

var rightNow = new Date();

 

// Get the millisecond value

// of the date object

var msRightNow = rightNow.getTime();

 

// Calculate 5 days in milliseconds,

// 5 days x 24 hrs/day x 60 min/hr x 60 sec/min x 1000 ms/sec

var fiveDays = 5 * 24 * 60 * 60 * 1000;

 

// Do Calculation var finalTime = msRightNow + fiveDays;

// Create a new Date from the calculated value

var theNewDate = new Date(finalTime);

 

// In actual working code on a form you'll want to place the

// result into a field value. But since this is test code we'll

// Print the result to the Console Window (Great for Debugging)

console.println("5 days from now is: " + theNewDate.toString());

 

The above is the exact code (cut&paste)

 

The Error I get here is;

ReferenceError: theNewDate is not defined

1:Console:Exec

undefined

 

I seem to get the "not defined" issue a lot...learning how to distinguish between the  undefined "type" undefined "variable" and undefined "value"

in this case "theNewDate" seems to be defined as a variable...equal to the current date plus the 5 days.... BUT I'm now "schooled" enough to "see" why I'm get the error....


Any thoughts....Anyone.....


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>