0

I'm using the library vue i18n to display the time and in my Date Localization file I have the following format:

export default {
    'nl': {
        short: {
            day: 'numeric', month: 'short', year: 'numeric'
        },
    }
};

and in the vue page itself I do this:

<td>{{ $d(new Date('2019-07-29 14:14:55'), 'short') }}</td>

Which works fine in Chrome and returns 29 jul. 2019. In Safari however, I get an invalid Date format error. I checked other questions here on SO and most of them suggested using Moment.js (which doesn't work for me because I'm already using vue i18n), others suggested adding the T character, Z character to the object or replace the - with a / or a combination of that. None of these suggestions worked for me. Any other ideas?

  • Use a valid string per [*ECMA-262*](http://ecma-international.org/ecma-262/10.0/#sec-date-time-string-format) (in this case, 2019-07-29T14:14:55), anything else is implementation dependent, see [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results). – RobG Aug 07 '19 at 12:47
  • As mentioned, I have tried the suggestions of other questions pointing this directions and it didn't work still :/. So even your suggestion didn't fix it. Before I got no errors in the console but your suggestion give a rise to this error: `[Vue warn]: Error in render: "RangeError: date value is not finite in DateTimeFormat format()"` –  Aug 07 '19 at 13:42
  • Fixing the format fixes your "invalid date in Safari" issue. I don't understand the Vue warning. – RobG Aug 07 '19 at 20:32
  • 1
    That's the thing, it doesn't. –  Aug 09 '19 at 08:41
  • possibly related to https://stackoverflow.com/questions/60566942/why-doesnt-intl-numberformat-work-with-units-in-safari-and-firefox – lenooh May 28 '20 at 09:40

0 Answers0