angular: [Safari only] Invalid argument for pipe 'DatePipe' - Safari cannot parse Date offsets

I’m submitting a …

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Error shows up, only on Safari (Version 10.0 (11602.1.50.0.10)) screen shot 2016-10-17 at 01 10 54

Expected behavior

Expected no error to show up. Google Chrome works fine

Minimal reproduction of the problem with instructions

Go to the following Plunkr with Safari and Google Chrome. Chrome works perfectly.

Plunkr: https://plnkr.co/edit/8ieBbla6Pk3jFQKkHsNc?p=preview

What is the motivation / use case for changing the behaviour?

So it works on Safari as well as Chrome

Please tell us about your environment:

Max OS X El Capitan 10.11.6

  • Angular version: 2.0.0

  • Browser: Chrome Latest, Safari 10.0 (11602.1.50.0.10), iOS Safari

  • Language: TypeScript 2.0.2

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 11
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

It’s still a bug in safari when you have date like that: 2017-11-02 00:00:00.000

edit: '2017-11-02 00:00:00.000'.replace(/\s/g, "T") this work’s in Safari and Chrome.

This issue is still here

This will work as a temporary solution. Of course, you can replace the replaced string value with what you require, e.g. hyphen instead of comma.

    formatDate(obj) {
        return obj.toString().replace(/,/g, "/");
    }

Then use it like this:

{{ formatDate(myDateObject) }}