How to display a DB UTC date without it being converted to local time

Hi @patrick,

I have a database date “2021-10-19T12:08:35.000Z” which comes through to the browser unchanged. I then apply formatDate(‘dd-MMM-yyyy HH:mm’) to format the date and it appears on the page as “19-Oct-2021 13:08”. So it looks like the formatDate function converts it to local time which for that date is UTC+1.

I want to display the UTC date, i.e. “19-Oct-2021 12:08”, so how do I format it without it being converted to local time?

Thanks
Allan

Easiest way is to remove the Z, it is then seen as a local timestamp date.replace('Z', '').formatDate(‘dd-MMM-yyyy HH:mm’)

Hi @patrick,

That does it! Many thanks for the super fast response, I appreciate it.

Thanks
Allan

1 Like