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

295
Visualizações
Why is the date in the request body different from the date in the response body in postman

I'm trying to post the date in the request body in postman

date_borrow: 2021-01-01 date_return: 2021-02-01

but the body response produces output

{
"success": true,
"message": "success",
"data": [
    {
        "date_borrow": "2020-12-31T16:00:00.000Z",
        "date_return": "2021-01-31T16:00:00.000Z"
    }
]

}

i use node.js express for rest-api

addBorrowingMember(req,res){
  let dataBorrowingMember = {
      date_borrow : req.body.date_borrow,
      date_return : req.body.date_return
  }

  pool.getConnection(function(err, connection) {
      if (err) throw err;
      connection.query(
          `
          INSERT INTO borrowing SET ?;
          `
          , [dataBorrowingMember],
      function (error, results) {
          if(error) throw error;
          res.send({
              success: true,
              message: 'success',
          });
      });
      connection.release();
  })

},

I want the date format the same as the request body like this date_borrow: 2021-01-01 date_return: 2021-02-01

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

It seems that you use postgresql as database and postgresql stores date in UTC +00.

To choose a timezone:

SELECT * FROM pg_timezone_names;

And set as below given example:

ALTER DATABASE postgres SET timezone TO 'Europe/Berlin';

Use your DB name in place of postgres in above statement.

over 4 years ago · Santiago Trujillo Relatório

0

Because you did not specify a timezone for express server, so the system defaulted the datetime to UTC … so there is a difference between the time you add ( even from the browser ) to the date saved by the server , it depends on the difference between your timeZone and the server UTC timeZone .

over 4 years ago · Santiago Trujillo 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