# Conver Decimal Number to HH:mm

**URL:** https://discourse.nodered.org/t/conver-decimal-number-to-hh-mm/56672
**Category:** Dashboard
**Created:** [14 January 2022 19:53 UTC](https://discourse.nodered.org/t/conver-decimal-number-to-hh-mm/56672 "2022-01-14T19:53:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![IAlves2022](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ialves2022/32/53866_2.png) [@IAlves2022](https://discourse.nodered.org/u/IAlves2022)
#### Post date: [14 January 2022 19:53 UTC](https://discourse.nodered.org/t/conver-decimal-number-to-hh-mm/56672/1 "2022-01-14T19:53:39Z")

</div>

Hello Guys,

So, i'm doing a dashboard to check all the stats on my electric car.  
It's all going, now i have a function to get the Charge Remaining Time, and i receive a decimal value, like the one the print screen i've shared, "5.5" so after this, i want to get a result like "5h:30min"

 ![Screenshot from 2022-01-14 19-43-05](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0dc8ea681a0395276466abf241d95e2518734ff4.png)

How can i achieve this?

Best regards

---

<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: [14 January 2022 20:35 UTC](https://discourse.nodered.org/t/conver-decimal-number-to-hh-mm/56672/2 "2022-01-14T20:35:32Z")

</div>

One trick You can use is the epoch since 01/01/1970  
converting the 5.5 to milliseconds and then using $fromMillis() JSONata expression to fromat the hours and minutes.  
e.g

```auto
[{"id":"39f9ee50.cd87aa","type":"change","z":"c791cbc0.84f648","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$fromMillis($$.payload * 3600000, \"[H]h:[m]m\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":860,"wires":[["c4f45a89.bcb1d8"]]},{"id":"c4f45a89.bcb1d8","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":860,"wires":[]},{"id":"d17a881.81b99f8","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5.5","payloadType":"num","x":110,"y":860,"wires":[["39f9ee50.cd87aa"]]}]

```

JSONata expression

```auto
$fromMillis($$.payload * 3600000, "[H]h:[m]m")

```

---

<div class="post-metadata">

### Author: ![IAlves2022](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ialves2022/32/53866_2.png) [@IAlves2022](https://discourse.nodered.org/u/IAlves2022)
#### Post date: [14 January 2022 21:02 UTC](https://discourse.nodered.org/t/conver-decimal-number-to-hh-mm/56672/3 "2022-01-14T21:02:17Z")

</div>

OMG Thank you for the response, exacly the result i wanted!!!

![Screenshot from 2022-01-14 21-00-48](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f75be92c54c46a1bf7034c544c82f2745ba8b557.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [28 January 2022 21:03 UTC](https://discourse.nodered.org/t/conver-decimal-number-to-hh-mm/56672/4 "2022-01-28T21:03:02Z")

</div>

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