# \[SOLVED\] Issue : display AM/PM time instead of 24hours

**URL:** https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947
**Category:** Dashboard
**Created:** [7 June 2019 14:27 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947 "2019-06-07T14:27:37Z")
**Posts on this page:** 15
**Page:** 2

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [1 January 2022 17:04 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/21 "2022-01-01T17:04:41Z")

</div>

It's a snippet of JavaScript. You would use it in a function node.

E.g...

```auto
var d = new Date();
msg.payload = d.toLocaleTimeString ("fr-FR", {hour12: false});
return msg;

```

However, where/why do you want to do this? Dashboard? If it is for dashboard then you can use angular formatters

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [1 January 2022 17:30 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/22 "2022-01-01T17:30:24Z")

</div>

Thanks for the fast reply.  
Yes! The X-axis of the line chart on dashboard is labeled in 12h format and I want to change this label to 24h format.

---

<div class="post-metadata">

### Author: ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)
#### Post date: [10 January 2022 14:23 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/23 "2022-01-10T14:23:28Z")

</div>

sorry for the late reply, did you find the solution to your problem?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 January 2022 15:35 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/24 "2022-01-10T15:35:15Z")

</div>

I believe the formatting is up to how your OS is setup to show times, and possibly how the browser is setup. It is not determined by node-red.

---

<div class="post-metadata">

### Author: ![Graefe](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Graefe](https://discourse.nodered.org/u/Graefe)
#### Post date: [20 December 2023 16:38 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/25 "2023-12-20T16:38:18Z")

</div>

This is an old thread but the problem still exists: no 24h format! I updated NodeRed to 3.1.3 and Node.js to 18.19. I tried Windows with Firebird and MS Edge and macOS with Firebird and Safari and iPadOS with Safari: no 24h format. Timedatectl under Debian prompts 24h format and the correct local time zone (CET). Any idea?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 December 2023 17:01 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/26 "2023-12-20T17:01:25Z")

</div>

Are you running the browser on the same Debian machine? If not what is the native date format on the machine running the browser?

Where exactly are you trying to get 24h format? Can you post a very simple flow that shows the problem?

Edit - or do you mean the x axis of the chart as in the previous posts?

---

<div class="post-metadata">

### Author: ![Graefe](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Graefe](https://discourse.nodered.org/u/Graefe)
#### Post date: [20 December 2023 17:26 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/27 "2023-12-20T17:26:52Z")

</div>

No, browsers are running on different machines, local time zone is set to automatic and results in CET as is in the Debian machine running NodeRed.

 ![IMG_1612](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/2372361938625746eca0d7e9988ee79beed314bf.jpeg)  
I am missing the 24h in the status text of the node-red-contrib-knx-ultimate nodes. I contacted the developer who told me that the nodes are showing 24h in his setting and that this behavior was independent from the node.  
 ![IMG_1613](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4db5f176ae8805bb6576bac18991cdfd6bcdb3e5.jpeg)  
Thank you

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 December 2023 18:23 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/28 "2023-12-20T18:23:30Z")

</div>

What timestamps do you see in the debug pane?

---

<div class="post-metadata">

### Author: ![Graefe](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Graefe](https://discourse.nodered.org/u/Graefe)
#### Post date: [20 December 2023 19:50 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/29 "2023-12-20T19:50:08Z")

</div>

24h format!

BTW: Status text of node-red-contrib-telegrambot-home nodes are pm/am only, as well.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 December 2023 21:23 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/30 "2023-12-20T21:23:33Z")

</div>

> [@Graefe](#):
>
> node-red-contrib-knx-ultimate

It is ok for me  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c7711b853b973f22b923c1088acb8a621e6b670.png)

Can you try a browser on a different device? Your phone for example?

---

<div class="post-metadata">

### Author: ![Graefe](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Graefe](https://discourse.nodered.org/u/Graefe)
#### Post date: [20 December 2023 21:37 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/31 "2023-12-20T21:37:35Z")

</div>

As I wrote:

> [@Graefe](#):
>
> I tried Windows with Firebird and MS Edge and macOS with Firebird and Safari and iPadOS with Safari: no 24h format.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 December 2023 22:13 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/32 "2023-12-20T22:13:53Z")

</div>

I wonder if it is something odd about your particular timezone in combination with those nodes. There is certainly something odd going on. Unfortunately I haven't got a free system that I can configure with your timezone.  
Having looked briefly at the code it appears to be converting it to a string in the server (rather than in the browser, which is more usual). It is using Date.toLocaleTimeString() so my guess is that nodejs 18 has a problem with toLocaleTimeString() in your timezone.

What does this flow show?

```auto
[{"id":"86dc1563d60cbd4d","type":"inject","z":"997da33a0beedade","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":1440,"wires":[["d897a08e9dc373d3"]]},{"id":"d897a08e9dc373d3","type":"function","z":"997da33a0beedade","name":"function 4","func":"msg.payload = new Date().toLocaleTimeString()\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":1440,"wires":[["361963660cc785f2"]]},{"id":"361963660cc785f2","type":"debug","z":"997da33a0beedade","name":"debug 2473","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":1440,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![Graefe](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Graefe](https://discourse.nodered.org/u/Graefe)
#### Post date: [20 December 2023 22:22 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/33 "2023-12-20T22:22:17Z")

</div>

"11:18:19 PM" 😔

I think the developer of this node uses CET, too. And he told me that 24h format works with his setup. I will ask him about his node.js.  
Concerning node.js: 16.x did not show 24h as well, here.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [21 December 2023 08:27 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/34 "2023-12-21T08:27:50Z")

</div>

> [@Graefe](#):
>
> he told me that 24h format works with his setup

What region is he in?

If in the flow I posted you replace the line in the function node  
`msg.payload = new Date().toLocaleTimeString()`  
with  
`msg.payload = new Date().toLocaleTimeString("en-UK")`  
what do you see.

As far as I can see, toLocaleTimeString defaults to the system locale, which I guess is 'en-US' so it shows AM/PM. If I use (in the UK) "en-US" in the call then I see AM/PM. If I am right then that is the problem. On a server with en-US as the region then it will show AM/PM and there is not much you can do about it, other than change the region in the server to en-UK

---

<div class="post-metadata">

### Author: ![Graefe](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Graefe](https://discourse.nodered.org/u/Graefe)
#### Post date: [21 December 2023 10:54 UTC](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947/35 "2023-12-21T10:54:47Z")

</div>

Ah, this helped me. Locale prompted LANG=C. After dpkg-reconfigure locales and changing the default to the desired local and a reboot everything is fine now. Thank you very much for your help!

[Previous page](https://discourse.nodered.org/t/solved-issue-display-am-pm-time-instead-of-24hours/11947.md?page=1)
