The application is written in express js, for robots with mongodb base I use mongoose and mongoose-ttl plugin to delete old records from the database. There is a model:
var mongoose = require('mongoose'); var ttl = require('mongoose-ttl'); var Schema = mongoose.Schema; var connection = mongoose.createConnection("mongodb://localhost/botSC"); var testSchema = new Schema({ title: String, genre: Array }); testSchema.plugin(ttl, { ttl: '1m' }); exports.Test = connection.model('Test', testSchema); server.js
var Test = require('../models/test').Test; module.exports = function (passport) { router.get('/test', function (req, res, next) { new Test({title: "hello", ttl: '2s', interval: "5s"}).save(function (err, result) { console.log(result); var date = new Date(); res.send(date); }) }); return router; }; The following entry is stored in the database:
{ "_id": "572078bc37eac5bc1f13bf26", "title": "hello", "__ttl": "2016-04-27T08:30:54.762Z", "genre": [], "__v": 0 } The page displays the following date:
"2016-04-27T08:30:52.764Z" But I must write down and print the following date:
Wed Apr 27 2016 11:30:53 GMT+0300 (Финляндия (лето)) What could be the reason for getting the date -3h and in an incomprehensible format?