Counter by day shift and night shift

Hello, I'm new in node red so basically I just understand to make counter by shift just using if, else if logic only but I've confused how to use the time format because it depends on AM PM format, can you help me what can I learn to make the counter by shift with other logic?


I see you are a busy little bee.

The timeformat is a called timestamp and is a number/value which is unique to NOW.
I think it shows the value in milliseconds since..... a fixed date way back when.
So no two values can/will ever be the same.

There is a moment node which translates from timestamp to human readable.
That may help. Not sure.

Can you share what have you done so far?

If you have timestamps as strings, you need to use the JavaScript Date functions to turn them back into JavaScript Date objects which, as Andrew has said, is a number of milliseconds since midnight January 1, 1970, UTC.

Date - JavaScript | MDN (

Date/Time calculations can get very complex and have lots of edge-cases so we really need to know more about what you want to achieve with the calculations in order to really be able to help. It is easy enough to use JS Date values to calculate elapsed ms. But something entirely different if you need to be able to translate that to a real date/time (due to daylight savings, leap-years, etc) and even more complex if you need to handle timezones.