1

I'm having trouble to understand how dates shows as string works.

I have this from my database, it is an string: "01/10/2018 11:25:12" in "DD/MM/YYYY HH:mm:ss" format, as far as I can understand it should be in UTC, so, when I translate it to my locale (my timezone is GMT+1) that should be what I should do:

{{ myDate: date:'short':'+1'}}

should present the time in my timezone, so, 12:25:12, but it's not.

After some research I realized that for my typescript "thinks" that the timezone for my string is GMT+2.

So, my question is, how is the timezone for this string suppose to be calculated?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
cucuru
  • 3,456
  • 8
  • 40
  • 74
  • It's a little bit difficult to tell what you're talking about here. An [MCVE](https://stackoverflow.com/help/mcve) would be extremely useful. – Matt Johnson-Pint Feb 20 '19 at 21:32

1 Answers1

0

You can pass a timezone to the DatePipe which is a string of the format +0100 (for your +1 hour plus) or a standard abbreviation e.g. Europe/Prague

timezone string
A timezone offset (such as '+0430'), or a standard UTC/GMT or continental US timezone abbreviation. Default is the local system timezone of the end-user's machine.

{{ myDate: date:'short':'+0100'}}

check the documentation here https://angular.io/api/common/DatePipe

jahller
  • 2,705
  • 1
  • 28
  • 30