Convert datetime with moment

Hi. I hope I can get some help from you guys.
I'm having a little trouble getting the date and time the way I want.
I have node red read temp and time from a mysql database, in the database the input of time is like this "2019-07-10 21:39:08" and out of node reds mysql it comes like this "2019-07-10T19:39:08.000Z"

I have added the moment node, but its only the date that is right, the time shows 00:00:00...
So its like this out of the Date/Time formatter: "10-07-2019 00:00:00"
What am I doing wrong?

That should work. I will test. Can you double-check that you are actually getting the date/time you think you are? Use a debug node to output the value that you are feeding into the moment node.

Yes I've checked with debug nodes. Out from the db is "2019-07-10T19:39:08.000Z"
and out from the moment node is "10-07-2019 00:00:00" :pleading_face:

Thanks for helping :grinning:

Nope. I've tried this and it works fine.

[{"id":"f086bf6d.7f374","type":"inject","z":"63281c77.40a064","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":440,"y":180,"wires":[["737aadca.38ea14","491774.d5a0188c"]]},{"id":"672a6b0e.c8ebf4","type":"debug","z":"63281c77.40a064","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":180,"wires":[]},{"id":"737aadca.38ea14","type":"moment","z":"63281c77.40a064","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Oslo","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD-MM-YYYY HH:mm:ss","locale":"en_US","output":"payload","outputType":"msg","outTz":"Europe/Oslo","x":640,"y":180,"wires":[["672a6b0e.c8ebf4"]]},{"id":"491774.d5a0188c","type":"debug","z":"63281c77.40a064","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":140,"wires":[]},{"id":"1cb7c5e7.9ff48a","type":"inject","z":"63281c77.40a064","name":"","topic":"","payload":"2019-07-10T19:39:08.000Z","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":220,"wires":[["491774.d5a0188c","737aadca.38ea14"]]}]

image

Settings the same as yours.

Can you show the output from the debug node?

To be doubly sure, I used a function node to make the payload an array as shown in your settings.

[{"id":"672a6b0e.c8ebf4","type":"debug","z":"63281c77.40a064","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":180,"wires":[]},{"id":"737aadca.38ea14","type":"moment","z":"63281c77.40a064","name":"","topic":"","input":"payload[0]","inputType":"msg","inTz":"Europe/Oslo","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD-MM-YYYY HH:mm:ss","locale":"en_US","output":"payload[0]","outputType":"msg","outTz":"Europe/Oslo","x":640,"y":180,"wires":[["672a6b0e.c8ebf4"]]},{"id":"491774.d5a0188c","type":"debug","z":"63281c77.40a064","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":140,"wires":[]},{"id":"1cb7c5e7.9ff48a","type":"inject","z":"63281c77.40a064","name":"","topic":"","payload":"2019-07-10T19:39:08.000Z","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":180,"wires":[["59d04603.cdee98"]]},{"id":"59d04603.cdee98","type":"function","z":"63281c77.40a064","name":"","func":"msg.payload = ['2019-07-10T19:39:08.000Z']\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":180,"wires":[["737aadca.38ea14","491774.d5a0188c"]]}]

image

Output as expected.

Can you also check what version of moment you have installed?

image

I also have 3.0.3. Strange...

Not strange maybe. The value is actually on msg.payload[0].TID not on msg.payload[0]

You can hover over the value and then copy the path using the 1st of the 2 icons to the right:

image

Ok and paste in where? Little confused right now. But thanks alot for quick replys!

In the "Input from" field in the moment node. You have payload[0], You need payload[0].TID.

It worked! Thanks alot. You saved the night for me :slight_smile:

Yes, you need to always check those references carefully. That's why Nick put in those buttons - to help you get the right path, just expand the output then click the button next to the entry you need to capture. The 2nd button copies the value, the 1st copies the property path.

Ok I will remember that. This is my 4th day with python, mysql and node red so its a lot to take in :grin:

Thanks again!