I'm doing something that should be really simple: I'm getting a string that represents an expiration date and using JavaScript to determine whether or not the expiration date has come to pass. My approach has been as follows:
var dateStringFromJson = "2015-09-11T11:21:48.113";
var expirationDate = new Date(Date.parse(dateStringFromJson));
if (expirationDate > new Date()) {
// Expiration not up
}
If I executed this function at a time before the expiration, say 10:50am, the comparison would fail and the function would act as if the expiration date was up.
I'm confident this problem has to do with JavaScript's timezone conversion. I'm in UTC-7 but my customers may be in any time zone across the U.S., so timezone specific fixes will not work here. I'd also prefer not to add an external library like moment.js to the project unless absolutely necessary.