Expand my Community achievements bar.

new Date() --> getYear() & getMonth() return strange/wrong values

Avatar

Former Community Member

Hi,

I am writing this Javascript under a text field initialize event of Livecycle:

var date = new Date();

xfa.host.messageBox("year "+date.getYear(),"Message",3);

xfa.host.messageBox("month "+date.getMonth(),"Message",3);

I get "113" for the first messageBox and "5" for the second.

Shouldn't they be 13 (or 2013) and 6 as we are in June 2013 now??

Thanks

1 Reply

Avatar

Former Community Member

Apparently solved, sorry for rush-asking the forum. I am using date.getFullYear() to have 2013 and I found that months are 0-indexed. Therefore, January is 0.

Thanks anyway