| | |
| | | var config = require('./config'); |
| | | |
| | | var moment = require('moment-timezone'); |
| | | var moment = require('moment'); |
| | | |
| | | //var a = moment(); |
| | | |
| | | var doc = {a:1, b:2, c:3}; |
| | | delete doc.a; |
| | | console.log(doc); |
| | | |
| | | |
| | | // var a = moment(); |
| | | // var b = a.format('YYYY-MM-DD'); |
| | | // var c = a.add(1, 'days').format('YYYY-MM-DD'); |
| | | // var c = a.add(-1, 'days').format('YYYY-MM-DD'); |
| | | // console.log(b); |
| | | // console.log(c); |
| | | // |
| | |
| | | // } |
| | | // } |
| | | |
| | | var mongoClient = require('mongodb').MongoClient; |
| | | |
| | | mongoClient.connect(config.mongo, { |
| | | poolSize: 10, |
| | | keepAlive: 300000, |
| | | auto_reconnect: true, |
| | | reconnectTries: 1000, |
| | | reconnectInterval: 5000, |
| | | connectTimeoutMS: 30000 |
| | | }, function(err, client) { |
| | | if (err) { |
| | | console.log(err.message); |
| | | return; |
| | | } |
| | | console.log('Connecting to Mongo DB at ' + config.mongo); |
| | | |
| | | var db = client.db('monitor'); |
| | | const collection = db.collection('data_hourly'); |
| | | |
| | | //moment().utcOffset("-08:00"); |
| | | moment.tz.setDefault("Asia/Shang_Hai"); |
| | | |
| | | collection.insertMany([{ |
| | | key:1, |
| | | date: moment(new Date().getTime() + 8*60*60*1000).toDate() |
| | | },{ |
| | | key:2, |
| | | date: moment(new Date().getTime() + 8*60*60*1000).toDate() |
| | | }], function(err2, doc2) { |
| | | if (err2) { |
| | | return; |
| | | } |
| | | |
| | | client.close(); |
| | | }); |
| | | }); |
| | | // var mongoClient = require('mongodb').MongoClient; |
| | | // |
| | | // mongoClient.connect(config.mongo, { |
| | | // poolSize: 10, |
| | | // keepAlive: 300000, |
| | | // auto_reconnect: true, |
| | | // reconnectTries: 1000, |
| | | // reconnectInterval: 5000, |
| | | // connectTimeoutMS: 30000 |
| | | // }, function(err, client) { |
| | | // if (err) { |
| | | // console.log(err.message); |
| | | // return; |
| | | // } |
| | | // console.log('Connecting to Mongo DB at ' + config.mongo); |
| | | // |
| | | // var db = client.db('monitor'); |
| | | // const collection = db.collection('data_hourly'); |
| | | // |
| | | // //moment().utcOffset("-08:00"); |
| | | // moment.tz.setDefault("Asia/Shang_Hai"); |
| | | // |
| | | // collection.insertMany([{ |
| | | // key:1, |
| | | // date: moment(new Date().getTime() + 8*60*60*1000).toDate() |
| | | // },{ |
| | | // key:2, |
| | | // date: moment(new Date().getTime() + 8*60*60*1000).toDate() |
| | | // }], function(err2, doc2) { |
| | | // if (err2) { |
| | | // return; |
| | | // } |
| | | // |
| | | // client.close(); |
| | | // }); |
| | | // }); |
| | | |
| | | // var june = moment("2014-06-01T12:00:00Z"); |
| | | // var a = june.tz('America/Los_Angeles').format('ha z'); |