Date format different in debug 'msg.payload' vrs 'complete msg object'

#1

Node-red v0.20.5
node.js v10.15.3
macOS 10.13.6

I just ran into a strange issue using debugs to display the date.

The flow is an inject connected to a function connected to two debug nodes - one displaying the complete msg object the other displaying msg.payload. The function is

msg.payload = new Date();
return msg;

Here is the flow and the debugs:

Notice the different way the date is being displayed. Shouldn't it show the same way??

[{"id":"73856941.30394","type":"debug","z":"425023c2.794014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":120,"wires":[]},{"id":"6fb74403.88b574","type":"function","z":"425023c2.794014","name":"Get date","func":"msg.payload = new Date();\nreturn msg;","outputs":1,"noerr":0,"x":620,"y":160,"wires":[["73856941.30394","3d5e32b1.27160e"]]},{"id":"a19ee0cf.193c58","type":"inject","z":"425023c2.794014","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":460,"y":160,"wires":[["6fb74403.88b574"]]},{"id":"3d5e32b1.27160e","type":"debug","z":"425023c2.794014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":810,"y":240,"wires":[]}]
#2

That is interesting and a bit odd, but it is of no consequence. They are both correct, and this is only for debugging after all.

#3

I know the dates are just in a different format and just wanted to make sure that it is an expected feature :stuck_out_tongue_closed_eyes:

#4

Well, I certainly would not have expected it.

#5

See https://nodered.org/blog/2017/01/11/version-0-16-released

"If it looks like a date expressed in milliseconds since epoch, another click will show the formatted date."

#6

Nope - clicking on the value in the debug does nothing, it's a string.

I added a node.warn in the function and it shows exactly like the the debug set to display msg.payload
"Wed Apr 17 2019 19:01:00 GMT+0200 (Central European Summer Time)"
while the debug displaying the complere msg object shows

{"_msgid":"eb1494f3.d5e1e8","topic":"","payload":"2019-04-17T17:01:00.036Z"}
so a conversion/formatting is going on when the complete msg object is displayed

#7

I don't think needs a huge debate. It is demonstrably treating it differently in the two places. Feel free to raise an issue.

#8

@knolleary I wasn't trying to cause a debate, I just wanted to point it out because I spotted it and it made me wonder if it was a known 'feature'