Date format headache

Debug sidebar has a very nice feature for values that look like unix timestamps, where you can click on it and immediately translate to human readable date. I should say human readable-ish, because I get horrendous formatting like M/dd/YYYY, h:mm:ss AM/PC [UTC+1]. So this is instant headache and potential source of bugs based on misunderstanding. So this must be a browser things sure? No possible fix in any browser I tried edge, chrome, firefox. But surely a plugin? Nah. But OS datetime format? Already have that set up in Windows 11 so clock shows YYYY-MM-dd. But somehow somewhere OS language is picked up. I prefer english language, possibly US or GB. But I never want those langauges to apply formatting! Anyone have a simple fix for this? Whenever I google browser formatting, it shows this is a discussed problem for years, but no solution.

It is such a pain I wish perhaps node red could take control and overwrite it regardless of browser/OS regional language format settings.

The first rotation of a date-like number should show the ISO8601 format representation:

Which is perfectly human readable isn't it?

Personally I always use ISO date/time formats as they are easily read and process well too.

2 Likes

Yes that's very good. But I also started appreciating converting to timezone. And the pandoras box opened.

I am not sure what you are asking for. Are you asking for node-red in the debug tab showing a timestamp, to not let the browser convert to the local time format for you but have a way of configuring node-red to show it in the format that you want?

For me, in the uk, when I click on the timestamp in the debug pane it shows ISO mode and then 19/03/2026, 11:29:49 [UTC0] which is what I expect when seeing local time format.

1 Like

Yeah preferably wish toconfigure node red to hardcode date format on local time, or it used some sensible format and regardless ignore browser and/or OS language. Because no where I look can I find a way to solve this. It works on my work laptop because I set windows language to Swedish (!) which has a nice date format that propagates into browser's locale, but it has some other consequences of getting swedish weekdays some times.

Asked chatgpt about it and it was insistant that browser couldn't solve this at all, and the only way to fix it was in source code :frowning:

I enjoy seeing this: 2026-03-19T13:52:09.994Z
But I hate seeing this: 19/03/2026, 11:29:49 [UTC0]
Or even this (which I see at home): 3/19/2026, 9:15:41 AM [UTC+1] :nauseated_face:

You have the luxury of having same local time as UTC :grinning_face_with_smiling_eyes:

What was the actual local time then? Maybe do it again now to check time and display.

The windows clock is adjusted correctly so assumed that configuration didn't have effect in browser/nr. So worst case it just reads windows language and defines format based on that. I don't want to change language on my home pc. Or I would have to go down the rabbit hole again and see which language is closest to english and still has sensible default date format.

So was the local time 09:15 and is your timezone UTC+1? If so then it is at least showing the correct time.

Looking at the code it appears to use Date().toLocalString() to format it, and then adds the timezone.

The time is certainly correct, but horrendous formatting. And I have no hope of browsers allowing to configure this, at least it has never worked for firefox, chrome an edge so far. Which means this is either handled by source code or OS language. And it's a bit much to change OS language to get date formatting in node red :stuck_out_tongue:

I thought there was an option in the editor settings to set the preferred language?
( but that may only be for the message translations)

I’m not sure you have actually shown us what a preferred date would look like to you.

Anything closer to or eual to ISO. Ie. something closer to 2026-03-20T08:17:20+00:00 UTC+XX:00 (but [UTC+1] is also fine) or similar to whatever NR shows for UTC. And much much further away from 3/4/2026, 6:17:20 PM [UTC+1] :scream: which is just begging for misinterpretation, false posisitives and positive negatives, introducing new bugs or investigating/fixing stuff which wasn't broken.

Windows clock which I am allowed to set myself I use YYYY-MM-dd HH:mm:ss which I do prefer, but even ISO is huge improvement over whatever browser decides is local.

According to my searches you can set the language in the browser, but I have not tried it.

The source for generating the output appears to be in the file packages/node_modules/@node-red/editor-client/src/js/ui/utils.js in the function formatNumber (search for toLocaleString). If you really want to change this you could fork node-red and edit it yourself and build your own node-red variant. The current code, if I have found the correct place, is

        } else if (format === 'dateML') {
            var dd = new Date(obj);
            element.text(dd.toLocaleString() + "  [UTC" + ( dd.getTimezoneOffset()/-60 <=0?"":"+" ) + dd.getTimezoneOffset()/-60 +"]");
        }

According to all my searches and findings, changing date format in browser is futile:
Setting Time and Date format in WIndows 11 / Edge - Microsoft Q&A
Switching from Chrome to Firefox, unable to set date/time format. : r/firefox

I tried this in firefox, but it didn't work:
How can I change the date format in Firefox without changing the language in Firefox? - Super User

This is an annoyance which I go down the rabbit hole once every other year, and each team ends up disappointed :frowning:

I must admit that for me it is not be a big issue, I am not sure I have ever looked at the local time version (before this thread). Even when we are in summer time (UTC+1) I tend to think in UTC when looking at times in the debug pane.

As a workaround you can put this in the debug node

[{"id":"bd8a209d91b053b1","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":20,"wires":[["8cc3554b1dbfc130"]]},{"id":"8cc3554b1dbfc130","type":"debug","z":"bdd7be38.d3b55","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"$fromMillis(payload, '[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]')","targetType":"jsonata","statusVal":"","statusType":"auto","x":360,"y":20,"wires":[]}]
1 Like

If clicking to cycle through the debug output formats till you get to the one you want is too annoying, which I can understand, how about inserting a dayjs node?

By default it will give an ISO date/time string, but you can format the output as you like, including changing timezones.

Incidentally, in making the above pic, I noticed that a debug node seems to remember and repeat the date format it last showed

1 Like

Hmm, that might benefit from some modernisation. We have the INTL library now which can output locale-specific formats.

I must admit though that I rather agree that, in general, locale dates are rubbish. "YYYY-DD-MM HH:mm:ss [timezone]" would likely be a much better option all round.

1 Like

Surely you mean YYYY-MM-DD hh:mm:ss.sss (TZ) ? ( in order of decreasing units)

And always happy to look at a PR

Oops! :smiley: Just checking people are awake of course. :flushed_face:

Will add it to my rather long list unless someone beats me to it (hopefully).

2 Likes

Yeah to remember last date format you chose is so awesome! However I'm looking at an array with thousands of datapoints, each with their own timestamp. Not sure if day.js is useful for that?

I suspect that you could use a change node with jsonata to apply day.js formatting to every array element.
I am sure it's possible but I don't know the syntax.