Time format conversion

You can do the calculation in the change node using moment().diff()
e.g.

   $moment($$.payload.sunrise).diff($moment($$.payload.sunset), "seconds")	

where msg.payload.sunset and sunrise are in format

{"sunset":"Sat Nov 25 2023 19:57:52 GMT+0100","sunrise":"Sun Nov 26 2023 07:57:52 GMT+0100"}

output in seconds

43200

Is this related to your other topic Problem with moment
If so please do not double post.

2 Likes