Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!