Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda