My issue lies with the datepicker using localized time instead of UTC when making calls to the backend. To handle this, I've created a function that adjusts the value before posting it to the server:
function adjustDateForTimeOffset(dateToAdjust) {
var offsetMs = dateToAdjust.getTimezoneOffset() * 60000;
return new Date(dateToAdjust.getTime() - offsetMs);
}
In addition, I have defaults that need to be in UTC and displayed correctly in the datepicker input box on application load. However, due to the datepicker using local time, the date appears consistently one day earlier in the input box.
I'm looking for a way to make the ui-date run on UTC time rather than local time at all times. Searching online has only provided solutions for adjusting dates before sending them to the server, which doesn't address my specific dilemma.