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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Two Integer Year

Avatar

Level 5

The following code is supposed to return a two digit year. However I am getting the two digit year with an "in" as a suffix.

var nd  = new Date();

var z = nd.getFullYear();

var y = z.toString();

var x = y.substr(2, 3);

app.alert("Variable nd = " + nd + "\n" + "Variable z = " + z + "\n" + "Variable y = " + y + "\n" + "Variable x = " + x);

the alert box upon showing up says:

Variable nd= Tues Nov 06 2012 11:51:11 GMT -0800 (Pacific Standard Time)

Variable z = 2012

Variable y = 2012in

Variable x = 12in

What is going on? "y" should equal 2012 as a string value and "x" 12 as a string value. Where is the "in" suffix coming from? Thanks.

2 Replies

Avatar

Level 10

Hi,

The problem you are having is because x and y are names reserved for the XFA object, so if this code was executing in button y would return you the y co-ordinate of the button, which must be in inches in your system.

Some other common names are w, h and index.

Regards

Bruce

Avatar

Level 5

Thank you Bruce.

var nd  = new Date();

var a = nd.getFullYear();

var b = a.toString().slice(2)

document.write("Variable nd = " + nd + " " + "Variable a = " + a + "" + "Variable b = " + b + "");