I've encountered an issue that I need help understanding. My goal is to convert a date into a more user-friendly format using the toDateString() method. However, I keep receiving an error message stating "toDateString() is not a function."
Currently, I am able to achieve this using toString():
truncateDate() {
if (this.employee && this.employee.dob)
{
let birthDate = this.employee.dob;
console.log(birthDate); // 2011-06-12T05:00:00.000Z Prints to console
console.log(birthDate.toString());
}
}
But when I try to use toDateString(), it results in an error:
truncateDate() {
if (this.employee && this.employee.dob)
{
let birthDate = this.employee.dob;
console.log(birthDate); // 2011-06-12T05:00:00.000Z Prints to console
console.log(birthDate.toDateString());
}
}
I'm unsure of what mistake I might be making here. Any insights would be appreciated.