he-IL Hebrew locale incorrect date format Angular 4

1.5k Views Asked by At

Using angular 4 date pipe to format dates. For he-IL (Hebrew) locale I see the data format as dd.mm.yyyy instead of dd/mm/yyyy

Not sure why this discrepancy?

2

There are 2 best solutions below

0
On

Add this to your pipe:

| date:'d/M/yy':'UTC+6'
0
On

I recommend using toLocaleDateString() in your case:

var date = new Date().toLocaleDateString('he-IL');
console.log(date);
date = date.replace(/\./g, '/');
console.log(date);