Compiling Date and Time to a readable value

Hello again
I can get the minutes, Seconds Hours, day, month and year from my device, but I cant figure out how to make it readable. Any pointers please? Thanks

  • Change the buffer parser to output a single value (disable fan out) & set the output type to key/value
  • Connect it to a function node containing...
const d = new Date(msg.payload.Year, msg.payload.Month-1, msg.payload.Day, msg.payload.Hour, msg.payload.Minutes, msg.payload.Seconds);
msg.payload = d
return msg;

See: Date - JavaScript | MDN

Cheers Steve.
Did this in the end, gives me just what I need so I dont have to visit the site. Cheers



image

You do realise that that isnt actually using the time from your modbus data right?

image

this is not how you use a typedInput...
image

Yeh, I just realized that now :slight_smile:

So in the example you gave me, const d = new Date(msg.payload.Year, msg.payload.Month-1, msg.payload.Day, msg.payload.Hour, msg.payload.Minutes, msg.payload.Seconds); msg.payload = d return msg;

Do I need to change the payloads to suite my output.

So I would have msg.payload.minute, msg.payload.second, and so on?

Well, since you already had that

I wrote a solution to suite...

So Sorry.
I get you now. I now have changed it and now it makes sense to me.
Thank you so much for your help.
I guess I need to visit site

image

Now its correct

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.