I have a datetime string and want to create a JS Date Object:
var dt_string = "2/10/2018 11:52:41 PM";
var d_object = new Date(dt_string);
I want to print the date/time in a different format (which just so happens to match the ISO String):
console.log("date/time: " + d_object.toISOString().substring(0,10) + " " + d_object.toISOString().substring(11,19));
I expect to see:
"2018-02-10 23:52:41"
Instead I get this:
"2018-02-11 04:52:41"
Which is 5 hours later than it's supposed to be. After debugging, I found this:
new Date(d_string): Sat Feb 10 2018 23:52:41 GMT-0500 (Eastern Standard Time)
Which makes me think it's adding 5 hours to my time to match GMT. How do I get JS to respect my original time, and not change it?