Reputation: 364
I try to store some Date on mongo Collections.
When I do let date = new Date(); MaCol.insert({'date': date});
, I can see on my mongo collection that the date is stored with the correct timezone
(something like : 2017-05-22 12:42:28.441Z).
But if I use a value on constructor of Date like let date = new Date('03/03/2000)
i lose the time zone : 2000-03-03 00:00:00.000Z
How to correct that ?
Thanks.
Upvotes: 0
Views: 101
Reputation: 2870
You should use moment.js to make this a breeze. They support a ton of options. In your case, using moment js, the below should work:
moment('03/03/2000').format();
>> "2000-03-03T00:00:00+05:30"
You can test other options by just visiting the momentjs page, opening up the dev console and directly typing in the above (or other format commands) to see if it gets you what you neeed.
Upvotes: 1