Change timestamp to type date
This commit is contained in:
parent
0450dff98f
commit
7bb02a8508
@ -28,21 +28,10 @@ function messageCallback(collection) {
|
||||
const id = topicElements.pop();
|
||||
|
||||
var date = new Date;
|
||||
var time;
|
||||
|
||||
if (date.getHours() <= 9) {time = "0" + date.getHours();} else {
|
||||
time = date.getHours();
|
||||
}
|
||||
if (date.getMinutes() <= 9) {time = time + ":0" + date.getMinutes();} else {
|
||||
time = time + ":" + date.getMinutes();
|
||||
}
|
||||
if (date.getSeconds() <= 9) {time = time + ":0" + date.getSeconds();} else {
|
||||
time = time + ":" + date.getSeconds();
|
||||
}
|
||||
|
||||
let doc = {
|
||||
device_id: id,
|
||||
timestamp: time,
|
||||
timestamp: date,
|
||||
}
|
||||
try {
|
||||
doc = _.merge(doc, JSON.parse(message));
|
||||
@ -63,4 +52,4 @@ function onMqttConnect(mqttClient) {
|
||||
console.log("Sucessfully subscribed...");
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user