Closed trisle closed 8 years ago
Could you please provide an example value for feed.created_at
?
It outputs a rather normal date string 2016-07-27 07:36:01
I assume it's correct as both Chrome and Firefox shows the relative date just fine.
The relativeDate
filter passes strings straight to the new Date()
constructor, which is notoriously inconsistent across browsers. There are two ways to fix this:
2016-07-27T07:36:01Z
Date
object to relativeDate
Thanks for the reply. I actually did try passing in a Date object but wouldn't help.
View
{{__date_obj(feed.created_at) | relativeDate}}
Controller
$scope.__date_obj = function(date_str) {
return new Date(date_str);
}
Still Chrome/Firefox works but not Safari :)
That has the exact same issue in that the new Date(string)
constructor is inconsistent across browsers. If you are going to construct a Date object, you either need to use an ISO 8601 string or use the new Date(year, month, day, hour, minutes, seconds)
form.
It works perfectly fine on Chrome but not on Safari
{{feed.created_at | relativeDate}}
Chrome: 5 hours ago Safari: Over a year from now
Might be related to this SO question?