Node-RED Date Time Formatter: What It Changes and When to Use It
A practical review of date and time formatting in Node-RED: what formatting actually does to your data, time zone and locale pitfalls, and when to keep a raw timestamp instead.
Formatting dates and times in Node-RED turns a machine-friendly value, usually a millisecond timestamp, into text that people can read. That is useful, but it is also a one-way change in most flows: once a timestamp becomes a string such as a month name and a clock time, the flow has traded precision and portability for readability. This review explains what the transformation does, when it suits your purpose, and when an unformatted value is the better choice.
A note on scope: no product-specific test results, version numbers or measurements were available for this review. The points below rest on general, verifiable behavior of JavaScript dates, the JSONata expression language that Node-RED uses, and date notation conventions. Check details against the documentation for the Node-RED version and any add-on nodes you have installed.
Is a date time formatter suitable for your use?
Short answer: formatting is the right step when the result is meant for a person to read, such as a dashboard label, a notification, an email body or a log line. It is the wrong step when the value will be stored, compared, sorted, sent to another system or processed later in the flow.
The main benefit is readability in the reader's own conventions. The decisive tradeoff is that a formatted string loses information unless you deliberately keep it: time zone, seconds, milliseconds, and sometimes even the year can disappear, and the text may not parse back reliably.
- Formatting is a good fit when:
- The output goes to a human-facing display or message.
- You state the time zone explicitly, either in the format or in the surrounding text.
- The original timestamp is still available elsewhere in the message or in storage.
- An unformatted value is preferable when:
- The data is written to a database, file or API.
- Other nodes compare, sort or calculate with the time.
- The audience spans regions with different date order conventions.
- You cannot control which time zone the Node-RED host runs in.
A practical pattern is to keep both: leave the raw value in one message property and put the formatted text in another, so display and processing never compete for the same field.
What does formatting actually change?
In this context, "formatter" means converting a date value into date notation. It has nothing to do with font styling, mirrored glyphs or reversed text, which are sometimes grouped under the same tool labels. The change is real, not cosmetic: the stored value in the message changes type, typically from a number to a string.
Node-RED's inject node, when set to send a timestamp, produces milliseconds since the Unix epoch. That number is unambiguous and time zone neutral. A formatter reads it, applies a time zone and a pattern or locale, and writes out text. Every one of those three inputs affects the result.
Stored change versus visual presentation
There are two places formatting can happen, and they behave differently. If you format inside the flow, with a function node, a change node using JSONata, or an add-on formatter node, the message payload itself becomes text and every downstream node receives the string. If you format only in a display widget that offers a display format option, the message keeps its raw value and only the on-screen rendering changes. The second approach is safer for anything that also feeds storage or logic.
Common ways to format in a flow
| Approach | Where it runs | Notes |
| Function node with JavaScript Date | Inside the flow | Built in; methods like toISOString always output UTC, while locale methods use the host time zone unless told otherwise |
| Function node with Intl.DateTimeFormat | Inside the flow | Built in; accepts a locale and a named IANA time zone, so daylight saving is handled |
| Change node with JSONata $fromMillis | Inside the flow | Built in; uses picture strings; the optional time zone argument is a fixed offset, not a named zone |
| Add-on formatter nodes from the community library | Inside the flow | Features vary by node; some depend on libraries their maintainers describe as legacy, so check maintenance status |
| Display format option in a dashboard widget | Presentation only | Leaves the message value untouched; availability and syntax depend on the dashboard package |
The simplest conversion, and a verifiable example, is turning a timestamp into an ISO 8601 string in UTC. An input of 0 produces 1970-01-01T00:00:00.000Z, the start of the Unix epoch.
// Function node: raw timestamp in, ISO 8601 UTC string out
msg.iso = new Date(msg.payload).toISOString();
return msg;
For local, human-readable output with daylight saving handled correctly, name the time zone instead of relying on the host setting. Keeping the result in a separate property preserves the original timestamp.
// Function node: readable US Eastern time, raw value kept in msg.payload
const fmt = new Intl.DateTimeFormat('en-US', {
timeZone: 'America/New_York',
dateStyle: 'medium',
timeStyle: 'short',
timeZoneName: undefined
});
msg.display = fmt.format(new Date(msg.payload));
return msg;
In a change node, JSONata offers a picture-string approach. Called with only a timestamp, $fromMillis returns an ISO 8601 string in UTC; with a picture and an offset it produces custom notation. Because the offset is fixed, a value such as -0500 will be an hour off during daylight saving time.
$fromMillis(payload, '[Y0001]-[M01]-[D01] [H01]:[m01]', '-0500')
The time zone trap
JavaScript date methods that do not take a time zone use the time zone of the machine running Node-RED, not the person viewing the result. A server, virtual machine or container may be set to UTC while users are elsewhere, so a flow that looks correct on a desktop can shift by hours once deployed. Naming the zone explicitly, or outputting UTC and saying so, removes that dependency.
Will the result stay readable and usable after copying or sharing?
Formatted dates are ordinary text, so they copy and paste like any other string. The problems are about meaning and processing, not about characters disappearing.
Ambiguous notation
Numeric dates are read differently across regions. In US notation, 03/04 means March 4; in much of the world it means April 3. Once such a string leaves the flow, nothing in it says which convention was used. Written-out month names or ISO 8601 order (year, month, day) avoid the ambiguity. A time without a zone label is similarly incomplete when shared across regions.
Hidden Unicode characters in locale output
Locale-aware formatting does not always produce plain ASCII. Recent Unicode locale data, which newer Node.js releases may include, uses a narrow no-break space (U+202F) rather than a regular space before AM or PM in US English time formats. The output looks identical, but exact string comparisons, regular expressions and some parsers that expect a normal space can fail. Formats for right-to-left locales such as Arabic or Hebrew may include invisible bidirectional marks that keep digits and separators in the right display order. These marks are correct for display but can surprise code that splits or compares the text. If formatted strings are going to be matched or parsed, test with the exact Node.js version in use rather than assuming plain spaces.
Locale support itself also depends on how Node.js was built. Builds with reduced internationalization data may fall back to a default locale, so a requested format can quietly come out in English. Verify output on the target host.
Sorting, search and editing
Strings sort alphabetically, not chronologically. A list of dates formatted with month names or US numeric order will sort incorrectly in tables, spreadsheets and databases. ISO 8601 strings in a single time zone with fixed-width fields are the exception: they sort correctly as text. Search has the same limit, since a query for a date only matches if it uses the identical notation. Editing a formatted value and feeding it back into a flow requires parsing with the same pattern, and any information dropped during formatting cannot be recovered.
Accessibility
Screen readers can announce compact numeric dates and abbreviations in ways that are hard to follow or ambiguous, while full month names and an explicit time zone are generally clearer in spoken form. No scoped tests of specific screen readers with Node-RED dashboards were available for this review, so how a particular assistive technology reads a given format is unconfirmed. If accessibility matters for your audience, test the actual display with the tools your users rely on.
When to keep a plain equivalent
Keep an unformatted value alongside any formatted one whenever the data will be stored, exported, compared, shared across regions or edited later. For timestamps, the plain equivalent is the original epoch milliseconds or an ISO 8601 string in UTC. The formatted text then serves as a label, and the raw value remains the source of truth.
Bottom line
Date time formatting in Node-RED preserves meaning for human readers when the time zone is explicit and the notation is unambiguous for the audience. It does not preserve practical usability for machines: formatted strings sort poorly, may contain non-obvious Unicode spacing or direction marks, and cannot always be parsed back. Format at the edge of the flow, name the time zone, and keep the raw timestamp in a separate property.