I am currently working on a project where the end date is set for February 12 (or any future date) and I am retrieving information from an API response.
The data obtained from the API response looks like this: {endDateTime:"1518393600000"}
In terms of UTC time and date, this response corresponds to Mon Feb 12 2018 00:00:00
However, when considering local time and date, the response translates to Sun Feb 11 2018 19:00:00 (GMT - 05:00)
My aim is to display the end date as Feb 12, 2018 on the user interface, but due to date conversion based on the local time zone, it shows Feb 11 as the end date. Below is the code snippet I have been using:
var d = new Date();
var c = d.setTime(parseInt($scope.project.endDateTime));
$scope.endDateTime = c;
Within the HTML markup:
<div> {{endDateTime}} </div>
I attempted to adjust the code in another way, however, it did not yield the desired outcome:
var d = new Date($scope.project.endDateTime);
var c = d.getUTCDate();
$scope.endDateTime = c;
Despite my efforts to tweak the code in various ways, I haven't been successful. Even after spending hours trying different approaches, I couldn't make it work. It's possible that I might be overlooking something very trivial. Any assistance or guidance on this matter would be highly appreciated! :)