Search code examples
javascriptformsadobeacrobat

getFullYear is not a function


I am trying to get the age based on two dates: Date of birth and date of visit. Everytime I try to use getFullYear(); in the following manner: I get the error that

var b = getField("dob").value;
var c = b.getFullYear();

I get this error in the console.

b.getFullYear is not a function
2:Console:ExecException in line 2 of function top_level, script Console:Exec

TypeError: b.getFullYear is not a function
2:Console:Exec
undefined

What am I doing wrong? I've tried all sorts of ways to make this work and the only thing that does is I use substring() to get the last 4 digits of the date.

The date is formatted as mm\dd\yyyy.

Thanks!


Solution

  • try var b = new Date(getField("dob").value);