Using Date.parse(“2017-02-13 04:33:00.0”) I’m shown that it’s NaN.
Using Date.parse(“2017-02-13 04:33:00”) without the millisecond results in a correctly parsed date.
Therefore, get rid of the milliseconds and you’ll be fine.
Thanks. Do you think getting rid of millisecond using javascript would do if it’s possible in the function somewhere or should I make changes in the webservice ?
If you have no requirement for the milliseconds, which is most likely to be true, adjusting the web service config is the most preferred path to success.
Hey Paul, I was actually testing this because the solution we discussed was not giving me today’s date. It was printing yesterday’s date. So, I have the following which works fine in IE 11 and shows NAN error in Chrome. Any idea why that could be happening? Here is my JSFiddle.
Dates are wonky. You need to throw a 00:00:00 timestamp on it as well to make sure it’s parsed as a local timestamp. It shows you yesterday, because it’s calculating off of 2017-06-01T00:00 UTC and using your local timezone to display it. So if you’re West of UTC, you’ll have -X to the time. If you look in the console, it’ll show you what your timezone is.
Is this for school or study? If it isn’t and you’re going to keep throwing different formats, timezones, and whatever else… you should probably just use moment.js.
This is for my work. I think it would be best to change from the backend to throw full timestamp then.
Haven’t tried using momemt.js. I will check that out. Do you think that should help in resolving the same issue without making changes from the back end?