Change DateTime format

Hi @ all,
at the moment I'm coming not to the solution about that.
How could I change the format 2018-12-13T07:03:00.000+0000
only to the time? (In that case to 07:03 or 7.30). Would be
great for any kind of help.

You can do this in several ways
One of them is to use a JSONata expression in a change node that will pick out a part of a payload

something like thisimage

replace start with a number that picks out the 0 from 07: and change length to be how many characters you want (5)

Where is that coming from and what type is it? Is it a string or a Unix timestamp or what?

Hi Colin,
it is coming from openhab and it is a DateTime type.
(openhab.0.items.astro_sun_home_rise_start)

Not sure what you mean by coming from openhab as I don't use openhab. Perhaps the best thing is to feed it into a debug node and show us a screenshot of the result.

Hi attached my screenshot.

I meant a screenshot of what you see in the debug node.
[Edit] so what is in the debug pane

I'm sorry...

Hi cymplecy ,
i try that but didn't work.

Well the first thing you can see from the debug is that the time is not in msg.payload, but in msg.payload.val, so you would need to provide payload.val in the change string.
Personally I would not do it like that, I would feed it into a moment node, I think that should be capable of doing what you want.
[Edit] That is node-red-contrib-moment

2 Likes

Since your time is in payload.val, try

image

1 Like

Thank you guys! :slight_smile: Wonderful job!

Colin your Idea was great, because by the
other example I had the prob that the seconds
were still there at the end. So thank you very much!!!