Search code examples
angulardate-pipe

Date pipe : LOCALE_ID does not affect the timezone?


In my app I sometimes display date and time like :

{{ object.dateStart | date:'shortDate' }} : {{ object.dateStart | date:'HH:mm' }}

In my app.module I do have :

import localeFr from '@angular/common/locales/fr';
registerLocaleData(localeFr, 'fr');
...
{ provide: LOCALE_ID, useValue: 'th' },

The date is indeed displayed in good format (dd/mm/aaaa) but the timezone is not applied : If I navigate on my website with a computer in an english timezone, time will be displayed with english timezone, but I want it to be always displayed with the LOCALE_ID timezone (french in my case). I could use :

{{ object.dateStart | date:'HH:mm':'UTC +2' }}

But then I have to specify timezone everywhere I need to display time. LOCALE_ID is not supposed to set the timezone? Is that a normal behaviour? Thx


Solution

  • Locale will only affect representation format and not timezone.

    You can refer to this site what Locale actually changes in general which you can observe in your angular code.

    http://www.localeplanet.com/icu/fr/index.html