0

I tried to stored date within mongodatabse database, there's difference between the server and local, I got always date - 1 hour within the server. Otherwise, I noticed a strange thing happened within the local, and here's an example :

  1. Get Object from the front contain a date :

    console.dir(req.body);

{ title: 'a',
date: '2018-01-20T00:00:28+01:00',
message:'a',
status: 'inDirectly',
active: true }

  1. Create a new record based on moongose schema that contain a date type :

    let newCommunication = new Communication(req.body);

  2. Then display the record like this :

    console.dir(newCommunication._doc);

    and I got :

{ _id:
ObjectID { _bsontype: 'ObjectID', id: Buffer [ 90, 98, 3, 99, 240, 231, 66, 2, 16, 200, 27, 192 ] },
active: true,
status: 'inDirectly',
message: 'a',
date: 2018-01-19T23:00:28.000Z,
title: 'a' }

  1. After that I saved, but in the database I got the real date, I mean the first and the correct one.

    enter image description here

    What's that mean ? And What I should do to correct that within the server ?

0 Answers0