While what colin showed you works, you should be aware that regular Numbers in JavaScript are only really good for about 10^53
e.g. Number.MAX_SAFE_INTEGER
results in 9007199254740991
fortunately, the number you are calculating is 1660141402000000
The safe way to do this in a function node is...
const buf = new Buffer.alloc(8)
buf.writeUInt16BE(msg.payload[3],0)
buf.writeUInt16BE(msg.payload[2],2)
buf.writeUInt16BE(msg.payload[1],4)
buf.writeUInt16BE(msg.payload[0],6)
msg.payload = buf.readBigInt64BE() // note this will be of type BigInt64
// or msg.payload = buf.readBigInt64BE().toString() // for a string: 1660141402000000
// or msg.payload = parseInt(buf.readBigInt64BE()) // to convert to regular Number
return msg;
Alternatively, without any functions, use Buffer-parser - designed specifically for making sense of PLC/modbus/buffers permitting you to create 1, 2, 3 (as many as you can) string/int/uint/32 bit, 64 bit, BCD etc etc - in one node (all at once).
Reading many registers and converting them all at once has the benefit of being consistent data ...
[{"id":"445423eb33b15f74","type":"buffer-parser","z":"b851e68919625d02","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bigint64le","name":"time","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":2430,"y":160,"wires":[["17ba904498e1ef93"]]},{"id":"5f0316999f769032","type":"function","z":"b851e68919625d02","name":"modbus (get 4 registers)","func":"msg.payload = [\n 2688,51851,58851,5\n]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2380,"y":100,"wires":[["445423eb33b15f74","526814b3820d55a3"]]},{"id":"6a0f9d393e9817de","type":"inject","z":"b851e68919625d02","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2190,"y":100,"wires":[["5f0316999f769032"]]},{"id":"526814b3820d55a3","type":"debug","z":"b851e68919625d02","name":"debug 57","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2620,"y":100,"wires":[]},{"id":"17ba904498e1ef93","type":"debug","z":"b851e68919625d02","name":"debug 58","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2620,"y":160,"wires":[]}]