Created
September 5, 2020 05:46
-
-
Save julioflima/d1ed7abe340ff5024a97ee45d1ee43c2 to your computer and use it in GitHub Desktop.
Rule, add a personalized date with moment timezone module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const moment = require('moment-timezone'); | |
module.exports = class SensorRule { | |
static date(req, res, next) { | |
try { | |
const { timestamp } = req.body; | |
const dateFull = new Date(timestamp).getTime(); | |
const date = moment(dateFull).tz('UTC').format('YYYY/MM/DD HH:mm:ss.SSSSSSSSS'); | |
req.body.date = date; | |
next(); | |
} catch (error) { | |
res.send(error); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment