Probably and easy answer to this but I can't seem to find a way to get moment.js to return a UTC date time in milliseconds. Here is what I am doing:
var date = $("#txt-date").val(),
expires = moment.utc(date);
Any idea what I am doing wrong?
is the way to go, since
does behave weird...
This is found in the documentation. With a library like moment, I urge you to read the entirety of the documentation. It's really important.
Assuming the input text is entered in terms of the users's local time:
If the user is instructed actually enter a UTC date/time, then:
I use this method and works. ValueOf not works to me.
If all else fails, just reinitialize with an inverse of your local offset.
Don't you need something to compare and then retrieve the milliseconds?
For instance:
With that you have the expiring date in UTC. Now you can get the "right-now" date in UTC and compare: