Folks, Having a difficult time with moment.js documentation.
record.lastModified = moment.utc().format();
returns:
2014-11-11T21:29:05+00:00
Which is Great, its in UTC... When I store that in Mongo, it gets stored as a String
, not a Date
object type, which is what i want.
What I need it to be is:
"lastModified" : ISODate("2014-11-11T15:26:42.965-0500")
But I need it to be a native javascript object type, and store that in Mongo. Right now if i store the above, it goes in as string, not Date object type.
I have tried almost everything with moment.js. Their toDate() function works, but falls back to my local timezone, and not giving me utc.
Thanks!
toDate()
function that you mention is what you want here. JavaScriptDate
objects always internally represent their time in UTC. Can you edit your question with the details on why you think that's not working? – Delousenew Date(moment.utc().format());
– Imago