I have created the following filter to convert MySQL dates and adjust time for the timezone relatively to UTC.
angular.module('HIS')
.filter('dateToISO', function () {
return function (input) {
var offset = new Date().getTimezoneOffset();
var date = new Date(input);
date.setTime(date.getTime()-offset*60000);
return date.toISOString();
};
});
Then, I use the filter to convert dates to my preferred format and show them inside HTML as follows. (I have changed the Angular interpolation tags to [[ ]]
to avoid conflicts with Laravel's blade syntax {{ }}
)
[[prescription.patient.first_name]] [[prescription.patient.last_name]]<br>
[[prescription.created_at | dateToISO | date:"EEEE, d/M/yy h:mm a"]]
This works fine with all the desktop browsers except for IE. Also this do not work for browsers in iOS(Safari/Chrome).
Working on desktop browsers except IE
Not working on iOS browsers and IE. The raw angular code is shown instead.
Important:
When I was searching, I found that the problem with IE was solved in Angular v1.3.3 and above. But I'm using v1.5.5 and still the problem is there. There was no clue on the Internet about this situation on iOS browsers. Can anyone explain why this happen and how to solve this?
Thanks in advance!