I'm trying to create a website to monitor the air quality in my room and I want to monitor the time where each measurement was taken. The problem is that when I get my data from my database and print it on my front end, the format of the time column is different from the database. This is the format of the time in the database:
2022-05-16 11:41:00+02
This is all fine and dandy, it contains the correct date and time, and it tells me that my timezone is UTC+2 (Denmark/Copenhagen). But when I need to use this exact date/time on my client, it is printed like this:
2022-05-16T09:41:00.000Z
So it changes the format by inserting the T and the .000Z in the end, as well as subtracting 2 from the hours. How do I change this formatting? Ideally I would like it to look like this:
16-05-2022 11:41
Do I need to define this in my query, or do I have to do it on my server? And how do I do it?
Good afternoon,
You could do like this:
SELECT to_char(current_TIMESTAMP (0) AT TIME ZONE 'Denmark/Copenhagen', 'DD-MM-YYYY HH:MM');