I am using mongodb
to save my dates, and I do it by doing new Date()
how can I convert my date to string to the output of new Date()?
let date="1969-03-07T05:00:00.000Z";
let new_date=new Date(date); //in my code it returns "Invalid date"
console.log(new_date);
console.log(new Date());
You might use Date.parse()
like:
let date = "1969-03-07T05:00:00.000Z";
let new_date = new Date(Date.parse(date));
console.log(new_date);
console.log(new Date());
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments