Backend quick-test environment - getFullYear is not a function

I am receiving an error of getFullYear is not a function. Is it possible that some function cannot be reached from the backend quick test environment.
Here is my code:
export function dateToString ( dDate ) {
let dtYYYY = dDate . getFullYear () * 10000 ;
let dtMM = ( dDate . getMonth () + 1 ) * 100 ;
let dtDD = dDate . getDate ();
let dtCalc = dtYYYY + dtMM + dtDD ;
let res = new String ;
res = dtYYYY + dtMM + dtDD ;
console . log ( "res= " + res + " dDate= " + dDate + " dtCalc= " + dtCalc + " dtMM= " + dtMM + " dtDD= " + dtDD )
return ( res . toString ());
}

Result when running the backend function:

Somebody can explain. Thanks

Looks like dDate is not of type Date. And dDate looks like an object with a key/value pair.

I am confirming that I am passing a date field:

let dtDeb = new Date ;
dtDeb . getDate (); // date aujourd’hui

@youge Could you test dtDeb immediately after creation with a typeof? For, in the back of my mind, I recollect that if you create a new Date without the brackets (new Date instead of new Date()), you get a string.

@giri-zano It is type of Date

@youge When creating a new date, you should call the class like this:

const dtDate = new Date();
1 Like