# Conversion and display milliseconds in the format "dd hh mm ss"

**URL:** https://discourse.nodered.org/t/conversion-and-display-milliseconds-in-the-format-dd-hh-mm-ss/74951
**Category:** General
**Created:** [9 February 2023 16:59 UTC](https://discourse.nodered.org/t/conversion-and-display-milliseconds-in-the-format-dd-hh-mm-ss/74951 "2023-02-09T16:59:57Z")
**Posts on this page:** 1
**Showing post:** 6

<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: [9 February 2023 22:17 UTC](https://discourse.nodered.org/t/conversion-and-display-milliseconds-in-the-format-dd-hh-mm-ss/74951/6 "2023-02-09T22:17:24Z")

</div>

here is is an example function.

```auto
let days = Math.floor(msg.payload / 86400000);
let hours = Math.floor(msg.payload / 3600000) % 24;
let minutes = Math.floor(msg.payload / 60000) % 60;
let seconds = Math.round((msg.payload % 60000) /1000);
msg.payload = `${days}d ${hours}h ${minutes}m ${seconds}s`;
return msg;

```

---

_[View the full topic](https://discourse.nodered.org/t/conversion-and-display-milliseconds-in-the-format-dd-hh-mm-ss/74951)._
