I am trying to subtract time now() with data from mysql.
Over here, M_Start = "08:15:00"
Example Current = "22:02:39"
My intention is to get total seconds of the different .
While using moment function : error message : "ReferenceError: moment is not defined (line 22, col 9)"
var ST_Target;
var Shift_Target;
var M_Start = flow.get('Morning_start');
var M_Stop =flow.get('Morning_end');
var M_sec = flow.get('Morning_sec');
var M_cycle = flow.get("Cycle_Time");
var dt = new Date();
var hour = dt.getHours();
hour = ("0" + hour).slice(-2);
var minute = dt.getMinutes();
minute=("0" +minute).slice(-2);
var sec = dt.getSeconds();
sec=("0" + sec).slice(-2);
var current = hour+":" +minute+":"+sec;
var d = moment.duration(current.diff(M_Start[0]));
I did install the module from the link below.
var momentjs = require("node-red-contrib-moment");
var ST_Target;
var Shift_Target;
var M_Start = flow.get('Morning_start');
var M_Stop =flow.get('Morning_end');
var M_sec = flow.get('Morning_sec');
.....
The error still persist -> "ReferenceError: require is not defined (line 1, col 16)"
Installing node-red-contrib-moment will add the Moment nodes to your palette. It does not cause the moment library to be available in the Function node.