# Calculating days and hours between two timestamps - Almost there.. Need a tweak on this!

**URL:** https://discourse.nodered.org/t/calculating-days-and-hours-between-two-timestamps-almost-there-need-a-tweak-on-this/74761
**Category:** General
**Created:** [6 February 2023 00:11 UTC](https://discourse.nodered.org/t/calculating-days-and-hours-between-two-timestamps-almost-there-need-a-tweak-on-this/74761 "2023-02-06T00:11:55Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [6 February 2023 07:52 UTC](https://discourse.nodered.org/t/calculating-days-and-hours-between-two-timestamps-almost-there-need-a-tweak-on-this/74761/3 "2023-02-06T07:52:02Z")

</div>

Error on first line, the division is done first, so parenthesis are required.  
Also the `diff -=` lines are not required.

```auto
let diff = (1675669264854 - 1675559264854) / 1000
var days = Math.floor(diff / 86400);
var hours = Math.floor(diff / 3600) % 24;
var minutes = Math.floor(diff / 60) % 60;

```

---

_[View the full topic](https://discourse.nodered.org/t/calculating-days-and-hours-between-two-timestamps-almost-there-need-a-tweak-on-this/74761)._
