# Wrong date format?

**URL:** <https://discourse.nodered.org/t/wrong-date-format/59449>\
**Category:** Developing Nodes\
**Tags:** function-node\
**Created:** [6 March 2022 18:08 UTC](https://discourse.nodered.org/t/wrong-date-format/59449 "2022-03-06T18:08:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fugit185](https://avatars.discourse-cdn.com/v4/letter/f/a87d85/32.png) [@fugit185](https://discourse.nodered.org/u/fugit185)\
**Post date:** [6 March 2022 18:08 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/1 "2022-03-06T18:08:13Z")

</div>

Hi,

I have this in Function node

```auto
var d = new Date();
//var dt = d.toLocaleString("fi-FI", { timeZone: 'Europe/Helsinki' });
var dt = d.toLocaleString("fi-FI");
msg.payload = dt + "," + msg.payload;
return msg;

```

accroding this

> **[W3Schools online HTML editor](https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tolocalestring_date_all)**
>
> The W3Schools online code editor allows you to edit code and view the result in your browser

I should get this

> 6.3.2022 klo 19.55.53

but I get this

> "3/6/2022, 20:01:26,temp"

i.e. month and day in wrong order?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 March 2022 21:19 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/2 "2022-03-06T21:19:07Z")

</div>

When I run your function, I get the correct format

 ![Screen Shot 2022-03-06 at 4.17.37 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/207c4ce6d1413a472357bd54e540344bb6f09f4f.png)

What version of NR and node.js? (you can find them in the start up log)  
What computer are you using?

---

<div class="post-metadata">

**Author:** ![fugit185](https://avatars.discourse-cdn.com/v4/letter/f/a87d85/32.png) [@fugit185](https://discourse.nodered.org/u/fugit185)\
**Post date:** [7 March 2022 13:02 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/3 "2022-03-07T13:02:37Z")

</div>

Hi,

I have updated to latest but I don't want to restart my NR, is there and other way to see NR version?  
I'm running it in Rasperry PI

---

<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:** [7 March 2022 13:23 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/4 "2022-03-07T13:23:21Z")

</div>

> [@fugit185](#):
>
> is there and other way to see NR version

It is at the bottom of the menu dropdown. Also in Manage Palette in the menu.

To get the nodejs version run  
`node -v`  
in a shell. It could be that you are using an old version. toLocaleString() did not work well in some versions.

---

<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:** [7 March 2022 13:36 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/5 "2022-03-07T13:36:35Z")

</div>

Finnish locales

> The all-numeric form for dates is in the order “day month year”, using a full stop as the separator. Example: “31.5.2002” or “31.5.02”. Years can be written with two or four digits, [nowadays](https://en.m.wikipedia.org/wiki/Y2K) usually with four, and numbers may be written with or without leading zero.

So the output would be correct for Finnish Locale.  
[https://hds.hel.fi/guidelines/data-formats](https://hds.hel.fi/guidelines/data-formats)

---

<div class="post-metadata">

**Author:** ![fugit185](https://avatars.discourse-cdn.com/v4/letter/f/a87d85/32.png) [@fugit185](https://discourse.nodered.org/u/fugit185)\
**Post date:** [7 March 2022 13:43 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/6 "2022-03-07T13:43:13Z")

</div>

Thanks, it is 2.1.4

---

<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:** [7 March 2022 13:48 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/7 "2022-03-07T13:48:02Z")

</div>

And the nodejs version?

---

<div class="post-metadata">

**Author:** ![fugit185](https://avatars.discourse-cdn.com/v4/letter/f/a87d85/32.png) [@fugit185](https://discourse.nodered.org/u/fugit185)\
**Post date:** [7 March 2022 13:49 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/8 "2022-03-07T13:49:25Z")

</div>

pi@tuotanto:~ $ node -v

> v12.22.7

and date in RPi

pi@tuotanto:~ $ date

> Mon 7 Mar 15:47:50 EET 2022

---

<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:** [6 May 2022 13:50 UTC](https://discourse.nodered.org/t/wrong-date-format/59449/9 "2022-05-06T13:50:24Z")

</div>

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