simple problem:
When I try this on console:
new Date('2018', '01', '08')
I get this output
Date 2018-02-07T13:00:00.000Z
How to get it to the date I just set? like 2018-01-08T00:00:00
?
Thanks a lot
simple problem:
When I try this on console:
new Date('2018', '01', '08')
I get this output
Date 2018-02-07T13:00:00.000Z
How to get it to the date I just set? like 2018-01-08T00:00:00
?
Thanks a lot
The month
parameter in the Date
constructor is 0-based, meaning the months start from 0, not 1.
To get January as your date, you need to set month to 0:
new Date('2018', '0', '08')
For UTC, you can use Date.UTC
to specify that the year, month and day are in UTC:
new Date(Date.UTC("2018", "0", "1"))
Apart from the answer above by Christian
, you can do the following to get current
local time:
new Date(new Date()+'utc');