I'm working on a Hotel application and the customers use UTC for communication. I completed mostly and I used everywhere date object like that => new Date() so before I run the application I want to change my local timezone like UTC and when I create new Date object it has to be UTC format. [![enter image description here]
I tried a lot of things, I tried tho expend Date object and when create date instance for everyone obejct I return our date instance. I didn't achieve. I have to get zimezone 0 of date object and I cant use any 3pr library.
providers: [{
provide: APP_INITIALIZER,
useFactory: initializeApp,
multi: true
}...]
export function initializeApp() {return () => {
const a = Intl.DateTimeFormat()
console.log(a);
Intl.DateTimeFormat(['en-US'], {
timeZone: 'UTC'
});
console.log(a);};}
To set the default timezone for your entire Angular application, you can use the
LOCALE_IDprovider along with theAPP_INITIALIZERin Angular. Here's an example:app.module.ts:initializeAppfunction in a separate file or within yourapp.module.ts:main.tsfile to use the locale from theLOCALE_IDprovider:In this example, the default locale is set to 'en-US', but you can change it to 'en-GB', 'fr-FR', or any other supported locale. The
initializeAppfunction is used to load locale data dynamically.Make sure to adjust the timezone and locale according to your requirements.