Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
How to change the format of the Timestamp type from outputted postgresql query?

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?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Good afternoon,

You could do like this:

SELECT to_char(current_TIMESTAMP (0) AT TIME ZONE 'Denmark/Copenhagen', 'DD-MM-YYYY HH:MM');

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda