0

I have the following code to show the provided date and time:

{{ product.availableFromUtc | date: 'mediumDate' }} {{ product.availableFromUtc | date: 'shortTime' }}

The DateTime is stored as UTC in the database (2020-08-25 14:30:29.6220000).

It is shown as: 25 aug. 2020 14:30

When I use {{ product.availableFromUtc | date: 'fullDate' }} {{ product.availableFromUtc | date: 'fullTime' }} to see the full object, it shows: dinsdag 25 augustus 2020 14:30:29 GMT+02:00

It needs to show 25 aug. 2020 16:30. What am I doing wrong, or what do I need to do in order to fix this?

A. Gh
  • 631
  • 9
  • 24
  • What if you try this ? `{{ product.availableFromUtc | date: 'd MMM. y HH:mm' }}`. UTC format will have 2 hours more (if you're french). You miss timezone (+0200 if you're french). – Emilien Aug 25 '20 at 15:03
  • @Emilien Then the result is shown as: 25 aug.. 2020 14:30 instead of 25 aug.. 2020 16:30 – A. Gh Aug 25 '20 at 15:06
  • It's a timezone problem, not a date format issue – Emilien Aug 25 '20 at 15:06
  • @Emilien I stored the DateTime objects in the backend as UtcNow or ToUniversalTime(), but changed it to store them as DateTime.Now and removed the ToUniversalTime() where it was being used. And now it is showing the proper date format (timezone). Thanks – A. Gh Aug 25 '20 at 15:14

0 Answers0