I'm having a challenging task. Angular application needs to show the date from the database object. It needs to stay the same, no matter where you are visiting the application. The only exceptions are the comments. I was testing this using Web Browser plugin.
I did a lot of research, but did not find a best practice. How would you solve this?
Currently I have created the following snippet:
// To-Do: Needs to account summertime
public dateToUTCDate(date: string | Date): Date {
const time = date instanceof Date ? date.getTime() : Date.parse(date.substring(0, 10));
return new Date(time + new Date(time).getTimezoneOffset() \* 60000);
}