Days between timestamps

I am looking for the number of days between two timestamps.

I have two timestamps which I want to compare to calculate the number of days they are apart.

Do you happen to know how to do the above or how to convert the timestamps to EPOCH timestamps?

Timestamps:

  • 2021-01-07T22:55:33.724Z
  • 2021-01-19T11:01:22+00:00

From where do you get these timestamps. If they are present with any entities in HA, you can simply use a get template node in nodered to find the difference. Just use a template like this.
Hope this would do the thing.

{{ as_timestamp(states.entity_id.state) - as_timestamp(state_attr('entity_id', 'state_value'))}} ```
const d1 = new Date("2021-01-07T22:55:33.724Z");
const d2 = new Date("2021-01-19T11:01:22+00:00");

msg.payload = (d2.getTime() - d1.getTime()) / 8.64e+7;

return msg;

@Kermit @sheminasalam Thanks they both work :muscle: