-1

I have the following object 2019-12-01. When I do:

console.log(typeof 2019-12-01);

The output is: NaN

So I want to convert this to string like this "2019-12-01" or to date object like:

Sun Dec 01 2019 02:00:00 GMT+0200 (Eastern European Standard Time)

I tried so many thing, but I cannot figure it out.

Any help will be appreciated.

1 Answers1

0

Why typeof, you can just create a date object

console.log(new Date("2019-12-01"))

console.log(new Date("2019-12-01").toISOString().replace(/T.*/, ""))
Akash Shrivastava
  • 1,365
  • 8
  • 16