I would like to convert the variable below to a date in the format of MM/DD/YYYY when i try to build the string I get a type error. I want the final variable to output 01/21/2022. How can I resolve this. I tried to change the variable from string to date. Is it that I need to use toString()?
UpdatedDate = Fri Jan 21 2022 00:00:00 GMT-0600 (CST);
var year = UpdatedDate.getFullYear();
var month = UpdatedDate.getMonth() + 1;
var day = UpdatedDate.getDate();
UpdatedDate = month + '/' + day + '/'+ year;
Type Error: Cannot find function getFullYear in object Fri Jan 21 2022 00:00:00 GMT-0600 (CST). (threadScript#1)
Thanks in advance, any help is appreciated.