I am making an AJAX request like the following:
$.ajax({
type: 'POST',
url: '@Url.Action("GetExpirationDates", "Products")',
data: data,
dataType: 'json',
success: function (data) {
var dateArray = data.map(function (date) {
var d = new Date(date);
return d.toLocaleDateString();
});
});
Here is what data
looks likes:
2016-02-25T00:00:00,2016-03-25T00:00:00,2016-04-25T00:00:00
It seems that as soon as I do new Date(date)
each one of these dates has a chance of showing as
2/24/2016, 3/24/2016, 4/24/2016
(one day less than it should be) depending on what the local time is. I am aware that this is most likely due to the way JavaScript handles timezones. I am wondering how to go about fixing it.