# Time and date not making sense to me

**URL:** <https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402>\
**Category:** General\
**Created:** [3 September 2020 12:42 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402 "2020-09-03T12:42:14Z")\
**Posts on this page:** 14\
**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:** [3 September 2020 12:42 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/1 "2020-09-03T12:42:15Z")

</div>

The time now (local) is 22:40 3 Sept 2020  
Give or take for the minutes/seconds.

This is an extract of a flow:

```auto
[{"id":"4b8ef85a.3c413","type":"inject","z":"242538c4.33ddf8","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"foo","payloadType":"str","x":950,"y":400,"wires":[["6f7a47b7.c516f"]]},{"id":"6f7a47b7.c516f","type":"function","z":"242538c4.33ddf8","name":"","func":"msg.payload = new Date();\nreturn msg;","outputs":1,"noerr":0,"x":1080,"y":360,"wires":[["55fe9b1f.9f8dcc","6aa131c7.5dd078"]]},{"id":"6aa131c7.5dd078","type":"debug","z":"242538c4.33ddf8","name":"Time now?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1260,"y":360,"wires":[]},{"id":"55fe9b1f.9f8dcc","type":"moment","z":"242538c4.33ddf8","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD/MMM/YY","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":800,"y":700,"wires":[["24878a03.064a9e","3773775b.e93c08","7f97eb1f.8519a4"]]},{"id":"7f97eb1f.8519a4","type":"debug","z":"242538c4.33ddf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":990,"y":650,"wires":[]},{"id":"3773775b.e93c08","type":"moment","z":"242538c4.33ddf8","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":800,"y":850,"wires":[["309edecd.303782","bc956c32.a9829"]]},{"id":"bc956c32.a9829","type":"debug","z":"242538c4.33ddf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":810,"wires":[]}]

```

I am making a clock. (Re-inventing the wheel)

So, all things are looking kind of good, but then I noticed the week day.

SUNDAY

All the `debug` nodes are showing me the right times and dates.

As per this picture.

 ![Screenshot from 2020-09-03 22-36-22](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d40cf15922bcf0045c92e7201b2b3334b0462b51.png)

It is the `moment` node.

The bottom one gets the _week day_ by having `ddd` in the field.  
To save you having to load the flow and look.  
I searched and `ddd` gives the week day in 3 letters.  
(Or that's what it said when I found it when I searched)  
All the same, I can't see 3 days difference between now and Sunday.

Now, even considering we are not using `Z` time which is shown in one of the `debug` outputs.....

I fail to see how today is Thursday, yet I am being told it is Sunday.

Yes: I've missed another elephant.  
But what can I say?

---

<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:** [3 September 2020 12:46 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/2 "2020-09-03T12:46:06Z")

</div>

You don’t show how you configured the moment node....

---

<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:** [3 September 2020 12:46 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/3 "2020-09-03T12:46:33Z")

</div>

I just posted it.

`ddd` for day of week.

---

<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:** [3 September 2020 12:48 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/4 "2020-09-03T12:48:23Z")

</div>

The complete configuration please

---

<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:** [3 September 2020 12:50 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/5 "2020-09-03T12:50:02Z")

</div>

```auto
[{"id":"3773775b.e93c08","type":"moment","z":"242538c4.33ddf8","name":"","topic":"","input":"","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd","locale":"en_AU","output":"","outputType":"msg","outTz":"Australia/Sydney","x":800,"y":850,"wires":[["309edecd.303782","bc956c32.a9829"]]}]

```

 ![Screenshot from 2020-09-03 22-49-13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a4743762e3e281dd743fc604124e99a84059224.png)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 September 2020 12:54 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/6 "2020-09-03T12:54:58Z")

</div>

It looks to me that you are daisy chaining the output of the moment nodes.

Try feeding the bottom node with the same input as the one above it

---

<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:** [3 September 2020 12:59 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/7 "2020-09-03T12:59:29Z")

</div>

Fair enough on that.

I'll try it, but if you see, it has the right date going into it.

 ![Screenshot from 2020-09-03 22-36-22](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73586610538ca7ccceac63261f73d834739caf16.png)

# WooHoo!

We found a bug - IMO

 ![Screenshot from 2020-09-03 22-57-20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ffeb67e377925193287e356025aa50696125412d.png)

But it is weird in the top picture you see the correct date being sent out.  
And even with all the _time offset_ you can't wrap from Thursday to Sunday by being in the wrong time zone.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [3 September 2020 13:12 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/8 "2020-09-03T13:12:40Z")

</div>

> [@Trying\_to\_learn](#):
>
> We found a bug - IMO

I think its not a bug - its just that the moment node doesn't understand the time format of 03/Sep/20

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [3 September 2020 13:31 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/9 "2020-09-03T13:31:24Z")

</div>

You havent defined in moment config that the date you want to process is from msg.payload  
its greyd out .. force it .. to payload

```auto
[{"id":"ebe82477.8506f8","type":"inject","z":"f54b08eb.e98bb","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"foo","payloadType":"str","x":710,"y":340,"wires":[["ec77bb8f.30e178"]]},{"id":"ec77bb8f.30e178","type":"function","z":"f54b08eb.e98bb","name":"","func":"msg.payload = new Date();\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":300,"wires":[["87b6c2a5.28e4b","bdada695.d332f8"]]},{"id":"bdada695.d332f8","type":"debug","z":"f54b08eb.e98bb","name":"Time now?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1020,"y":300,"wires":[]},{"id":"87b6c2a5.28e4b","type":"moment","z":"f54b08eb.e98bb","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD/MMM/YY","locale":"en_AU","output":"dt","outputType":"msg","outTz":"Australia/Sydney","x":560,"y":640,"wires":[["bbf47a06.78ea2","726df110.86888"]]},{"id":"726df110.86888","type":"debug","z":"f54b08eb.e98bb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"dt","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":590,"wires":[]},{"id":"bbf47a06.78ea2","type":"moment","z":"f54b08eb.e98bb","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd","locale":"en_AU","output":"dt","outputType":"msg","outTz":"Australia/Sydney","x":560,"y":790,"wires":[["d03fc65c.a47098"]]},{"id":"d03fc65c.a47098","type":"debug","z":"f54b08eb.e98bb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"dt","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":750,"wires":[]}]

```

but maybe you are right .. the moment node should have notified that its unconfigured .. or maybe its not really defaulting to ... msg.payload?!

my test configuration

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13b2732f611ac426e24b4f629858d5ff0028cfad.png)

**Output in msg.dt**

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fafdf102d853cd03c40ae2b65aaa500678fbc1be.png)

---

<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:** [3 September 2020 15:58 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/10 "2020-09-03T15:58:29Z")

</div>

> [@UnborN](#):
>
> but maybe you are right .. the moment node should have notified that its unconfigured .. or maybe its not really defaulting to ... msg.payload?!

If the moment node receives an invalid input, it should output a warning message to debug. I haven't looked at the code recently but I'm pretty sure that if it gets something it can't deal with it outputs an empty string.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [3 September 2020 17:14 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/11 "2020-09-03T17:14:12Z")

</div>

In this case @Trying_to_learn clicked done in configuration without defining input and output, even if there was a big fat **RED** highlight on those fields 😃

Andrew companies should hire you as a software tester. You haven't left a node in node-red un-penetrated from every single input-output with every possible value. numbers arrays objects dates .. you name it 😉

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [3 September 2020 20:19 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/12 "2020-09-03T20:19:46Z")

</div>

> [@UnborN](#):
>
> even if there was a big fat **RED** highlight

Well, thin (1-2px) red highlight to be exact. 😉

---

<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:** [3 September 2020 22:10 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/13 "2020-09-03T22:10:51Z")

</div>

I did see that and even filling in the `payload` made no difference to the output.

But, yes, I probably should fill the field in.

---

<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:** [17 September 2020 22:11 UTC](https://discourse.nodered.org/t/time-and-date-not-making-sense-to-me/32402/14 "2020-09-17T22:11:11Z")

</div>

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