# Need help with a sub-flow and dates (sorry folks)

**URL:** <https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740>\
**Category:** General\
**Created:** [6 March 2020 21:35 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740 "2020-03-06T21:35:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 21:36 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/1 "2020-03-06T21:36:00Z")

</div>

Ok, I have shared a "node" (Sub-flow) recently which has three outputs.  
`msg.payload` that is suitable for use as a file name.  
`msg.payload` that is suitable for use as a path.  
`msg.time` which is suitable for use as a file name.

It works.

Well, it kind of does and kind of doesn't.

I posted it to the forum and didn't get any feedback on a problem so I thought all was good.  
But then locally I started to see problems.

Rather than the output being YYYY-MM-DD it was YYYY-DD-MM which is annoying when looking at time lines.

I opened the sub flow and looked at it and was shocked to see when I used the `moment` node, I had goofed and put `YYYY-DD-MM` by _mistake_. (Or so I thought)

I quickly changed the code to `YYYY-MM-DD` and thought nothing more of it.

Today, I am going through checking things and am **still** seeing the output as DD-MM.

I have checked two of my 3 Raspies and they are both doing it.

Weirdly the third isn't.

Also the NUC - this machine - is also doing it - wrong format.

To further confuse me, the code is the sub-flow is correct in that it says `YYYY-MM-DD`  
Yet the output isn't. It is `YYYY-DD-MM`

Thoughts?

 ![Screenshot from 2020-03-07 08-19-08](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f3db18e5cfecd7f90a382e9f059710e40b7a93f.png)  
 ![Screenshot from 2020-03-07 08-19-16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/efeab71131d7b07ae846384fde27a361debbe7c9.png)  
 ![Screenshot from 2020-03-07 08-19-27](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d3ba02cbc590006f82d57e0d632b59626d6267a.png)

Though I haven't circled all the problems - as looking it it a bit harder you can see it is worse than I show - you get the idea.

This is the code for the three machines:

 ![Screenshot from 2020-03-07 08-25-00](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e2ac28100c2848a9dd2513e4977dd176d3662cb8.png)

 ![Screenshot from 2020-03-07 08-28-36](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a40dc050773a176383b5f33e741a1ddcf6330bd.png)

 ![Screenshot from 2020-03-07 08-30-17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/a/4a28fdadd853c4a958acd4f109bab3fd75c89a29.png)

And for total inclusion this is from the NUC:

 ![Screenshot from 2020-03-07 08-34-41](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57e7f2099ada558db9a6eb866b2f01784320ee31.png)

I'm obviously missing an elephant in the room.

Anyone?

P.S.  
I've moved the "subflow" up to the edit level and made a normal flow of it.

For your assistance to helping me understand what is happening:

```auto
[{"id":"313e36fb.b31f22","type":"function","z":"8aae5d25.29cda","name":"Time Stamp","func":"var d = new Date().toLocaleString();\nmsg.payload = d;\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":330,"wires":[["caa524bf.b5eb5"]]},{"id":"caa524bf.b5eb5","type":"moment","z":"8aae5d25.29cda","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-DD-MM HH:mm:ss","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":420,"y":330,"wires":[["183c417e.5ff80f","2aa29446.e3b18c","44c65d67.898004"]]},{"id":"183c417e.5ff80f","type":"string","z":"8aae5d25.29cda","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":":"},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":" "},{"type":"str","value":""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":470,"y":430,"wires":[["1d4c891d.8581bf"]]},{"id":"2aa29446.e3b18c","type":"change","z":"8aae5d25.29cda","name":"TOPIC","rules":[{"t":"move","p":"payload","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":380,"wires":[["729727c3.bfca3"]]},{"id":"3f32eab6.ff56e6","type":"change","z":"8aae5d25.29cda","name":"Save","rules":[{"t":"set","p":"payload","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":290,"wires":[["313e36fb.b31f22"]]},{"id":"729727c3.bfca3","type":"change","z":"8aae5d25.29cda","name":"Get","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":380,"wires":[["5ed635f.678a64c"]]},{"id":"d8ad12e6.c3e7f8","type":"inject","z":"8aae5d25.29cda","name":"","topic":"","payload":"foo","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":290,"wires":[["3f32eab6.ff56e6"]]},{"id":"44c65d67.898004","type":"debug","z":"8aae5d25.29cda","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":660,"y":330,"wires":[]},{"id":"5ed635f.678a64c","type":"debug","z":"8aae5d25.29cda","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"time","targetType":"msg","x":660,"y":380,"wires":[]},{"id":"1d4c891d.8581bf","type":"debug","z":"8aae5d25.29cda","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":660,"y":430,"wires":[]}]

```

---

<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 2020 22:04 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/2 "2020-03-06T22:04:39Z")

</div>

Andrew, in the flow you provide the moment output is `YYYY-DD-MM HH:mm:ss`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 22:14 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/3 "2020-03-06T22:14:09Z")

</div>

Yeah, I know.

I shall have to admit I may have goofed. Kind of.

But indulge my stupidity, because things are still as confusing as ever for me.

You said the output is `YYYY-DD-MM` which would imply that I am getting an **incorrect** output.

Here's the _rub_!

To try and work out the problem I again simplified the flow to:

 ![Screenshot from 2020-03-07 09-08-31](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/1/81b8bd58d993775bc4825cbabda60d94945a46b6.png)

Note the nice numbering: 1 and 2.

1 is _wrong_. 2 is _right_.

But it isn't all it seems.

Look at the screen shots:

 ![Screenshot from 2020-03-07 09-05-47](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1baf81b29d9f44a2e3ff8bc56cd5d548c2e0d388.png)

 ![Screenshot from 2020-03-07 09-05-55](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/2697141b5cbf67c4e42e4873a66cb51a49cd6e32.png)

Conclusion:

Originally I uploaded the code with the date formatted as `YYYY-DD-MM` and after local looking I saw a problem. ie: 2020-14-01 for example.

I changed the format to `YYYY-MM-DD` and thought nothing more of it.

Now when I am doing _house keeping_ I am still seeing the problem.

There seems to be a problem with how the `moment` node is parsing the date.

When I have it set to do `YYYY-DD-MM` I am getting the desired output (eg) 2020-03-07 for today

When I have the node to do `YYYY-MM-DD` I get 2020-07-03

Or am I again missing something?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 22:18 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/4 "2020-03-06T22:18:03Z")

</div>

Here is the flow:

```auto
[{"id":"981247e6.8d8b","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"foo","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":400,"wires":[["35804bcb.cfa3b4"]]},{"id":"35804bcb.cfa3b4","type":"function","z":"a941e919.4a7d88","name":"Time Stamp","func":"var d = new Date().toLocaleString();\nmsg.payload = d;\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":400,"wires":[["a14fc634.236a58","1e45ce85.75bc79"]]},{"id":"a14fc634.236a58","type":"moment","z":"a941e919.4a7d88","name":"1","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm:ss","locale":"en_AU","output":"payload","outputType":"msg","outTz":"Australia/Sydney","x":440,"y":400,"wires":[["b475d6b2.e14ce"]]},{"id":"1e45ce85.75bc79","type":"moment","z":"a941e919.4a7d88","name":"2","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-DD-MM HH:mm:ss","locale":"en_AU","output":"payload","outputType":"msg","outTz":"Australia/Sydney","x":440,"y":440,"wires":[["3e04c264.1fa166"]]},{"id":"b475d6b2.e14ce","type":"debug","z":"a941e919.4a7d88","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":730,"y":400,"wires":[]},{"id":"3e04c264.1fa166","type":"debug","z":"a941e919.4a7d88","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":730,"y":440,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 22:23 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/5 "2020-03-06T22:23:14Z")

</div>

(Sorry.....) To not want to trip you up on edited posts.

Another thing which is really confusing to me with the flow:

It is an `inject` node going to a `function` node which gets the current local time  
That is split into two `moment` nodes and their outputs sent to their respective `debug` node/s.

Look at the times!

There is 20 seconds difference.  
1 gets its message. 20 seconds later 2 gets its.

That is a (or should be) a worry.

 ![Screenshot from 2020-03-07 09-05-28](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3eeb30a1f1e430374f3723bcee6ae62f7aaed14f.png)

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [6 March 2020 22:31 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/6 "2020-03-06T22:31:53Z")

</div>

Your flow works as expect for me here in the USA so I suspect the issue has something to do with how your country generally represents time combined with this:

var d = new Date().toLocaleString();

Try removing the function node:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/86637b4b4d9872a83153ae919ea91d0437d54154.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 22:35 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/7 "2020-03-06T22:35:48Z")

</div>

> [@jtmoderate876](#):
>
> Try removing the function node:

Thanks.

Alas, if only it was that easy.

The idea is that I am wanting to generate a time stamp and the input is not guaranteed to be a timestamped message.

The node gets an input and generates an output (3 actually) for use as needed:  
For logging  
as {msg.time}  
For use as a file name.

Indulge me the problem with the reversed `MM-DD` and if you are seeing that.  
(That `MM-DD` gives mm-dd output, and `DD-MM` gives mm-dd output)

For clarity, check the picture:  
The "raw" message being sent to the `moment` node,  
The output of the `MM-DD` node - note the date is date-month  
The output of the `DD-MM` node - note the date is month-date

And how long it took.

 ![Screenshot from 2020-03-07 09-38-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/71e99b273f984b05dc82103fec58769d4ceb6533.png)

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [6 March 2020 22:41 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/8 "2020-03-06T22:41:44Z")

</div>

From the info tab for the moment node:

#### String input warnings

Note that parsing date/time strings is a hard problem. moment.parseFormat helps but it isn't magic. We assume that ambiguous input dates such as `3/5/05` are in EU/UK format `dd/mm/yy`_unless_ either the input timezone is in _America_ or the locale is set to _en\_US_ .

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 22:45 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/9 "2020-03-06T22:45:54Z")

</div>

So where do I check if it is set to en\_US or EU/UK?

The output from the `function` node is EU/UK format (date month) and it is asked/told to get local time  
`new Date().toLocaleString();`

So to my understanding that is set correctly for here.

And the `moment` local is set to `en_AU`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 22:54 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/10 "2020-03-06T22:54:30Z")

</div>

That didn't seem to help.

 ![Screenshot from 2020-03-07 09-52-46](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6affce80b2166a6ac65be8299cc4ad22c3bc3d4.png)

```auto
e@me-desktop:~$ sudo dpkg-reconfigure tzdata
[sudo] password for me: 

Current default time zone: 'Australia/Sydney'
Local time is now: Sat Mar 7 09:56:20 AEDT 2020.
Universal Time is now: Fri Mar 6 22:56:20 UTC 2020.

me@me-desktop:~$ 

```

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [6 March 2020 23:04 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/11 "2020-03-06T23:04:37Z")

</div>

the output of your function node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/8/1813c37469dfa5910278f201a5705a3c33c0d799.png)

is in the format of m/d/yyyy not EU/UK format and their notes state:

- 

> We assume that ambiguous input dates such as `3/5/05` are in EU/UK format `dd/mm/yy`_unless_ either the input timezone is in _America_ or the locale is set to \*en\_US .

-

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 23:11 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/12 "2020-03-06T23:11:09Z")

</div>

Yeah. Fair enough for that.

For me, I like dd mm yyyyy.  
But for time lines I prefer yy mm dd

The javascript command gives `3/7/2020`. That is what is given to the node to derive the date.

So I'm guessing it is a node problem.

Am posting information to the person now.

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [6 March 2020 23:16 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/13 "2020-03-06T23:16:32Z")

</div>

You could just move to the United States to get it to work 🙂.

---

<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 2020 23:16 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/14 "2020-03-06T23:16:46Z")

</div>

Why are you using a function node to get the date/time when you can use a change node to add a timestamp to the msg?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 23:17 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/15 "2020-03-06T23:17:22Z")

</div>

With 60c/dollar conversion rate..... Not just now.

2011 when it was 1:1, maybe......

Where abouts are you? (Just asking)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 23:17 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/16 "2020-03-06T23:17:58Z")

</div>

Because I didn't know I could do that.

I'll look into that now.

Thanks.

---

<div class="post-metadata">

**Author:** ![jtmoderate876](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jtmoderate876/32/6423_2.png) [@jtmoderate876](https://discourse.nodered.org/u/jtmoderate876)\
**Post date:** [6 March 2020 23:21 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/17 "2020-03-06T23:21:04Z")

</div>

> [@Trying\_to\_learn](#):
>
> Where abouts are you?

Suburbs of Chicago.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 23:23 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/18 "2020-03-06T23:23:52Z")

</div>

Wow! Ok. Been there ........ 5 times.

Only transit alas. Going to Oshkosh.

But I do know an "Ozzie" who moved there way back in the late 80's.

Small world.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 March 2020 23:26 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/19 "2020-03-06T23:26:50Z")

</div>

(Bit off topic)

That seems to work.

As it is a `sub-flow`, I keep text copies of these.  
I've forgotten how to export the subflow to the clip board?  
I do remember there was a problem that the `in` and `out` nodes of the subflow weren't included in the exporting.

Don't worry!

Just remembered. Select the node and export. Though I think that has the problem I mentioned associated with it.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [7 March 2020 15:31 UTC](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740/20 "2020-03-07T15:31:39Z")

</div>

Dear all,

I've only just spotted this and nearly missed it. I could have sorted this for you a lot quicker had I known from the title that you were using the moment node 😉

As my warning states, trying to identify correct dates from locale-specific inputs is a nearly impossible job. Because I am based in the EU (urm well I was until some twats messed things up - apologies for the expletive), I decided to make that the default if the input was ambiguous as it is in this case.

I would note that all of this would be avoided if you used the ISO format for dates (YYYY-MM-DD) instead of locale-specific formats. I adopted that years ago on my PC and in my software (Excel, etc). It sorts naturally as text and completely avoids ambiguity.

So when handling dates and timestamps, here are the foundation rules that I work to:

- **Always use ISO date format where possible** (YYYY-MM-DD)

- **Always work in UTC** (Aka Zulu time or GMT) except when displaying to the user

- **When needing a string format for timestamps, always use ISO format**

- **When specifying decimal seconds in a timestamp, avoid more than 3 decimal places**

[Next page](https://discourse.nodered.org/t/need-help-with-a-sub-flow-and-dates-sorry-folks/22740.md?page=2)
