I have been wrestling with this for a couple hours now at least and would really appreciate any insight as to what I'm doing wrong.
I want to compare 2 date objects and need to convert one date that I'm grabbing from a datetime input. when I put the variable being set into a new Date(myVariableHere); it doesn't work, though if I add in the string equivalent new Date(2014-01-05T04:47Z); it works fine (so it seems).
My fiddle here: http://jsfiddle.net/centinel3/Y8kWf/
note: I tried also using moment.js and wasn't able to make it do what I needed it to.
Some code snippets below and thank you in advance.
// HTML
<input id="start-date" type="datetime"/>
// Gets value from start date "datetime selectbox"
var userStartDate = "";
$("#start-date").change(function () {
userStartDate = $(this).val();
});
var startDate = new Date("2014-01-05T04:47Z"); // works
var startDate = new Date(userStartDate ); // doesn't work
Working/fixed code below (this also adjusts the format so that it plays well in safari:
var userStartDate, startDate;
$("#start-date").change(function () {
userStartDate = ($(this).val()).replace(/-/g, "/").replace("T", " ");
startDate = new Date(userStartDate);
});