# Node "moment", output format "calendar", different results

**URL:** https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697
**Category:** General
**Created:** [6 March 2020 10:24 UTC](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697 "2020-03-06T10:24:19Z")
**Posts on this page:** 5
**Page:** 2

<div class="post-metadata">

### Author: ![QbaF](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/qbaf/32/51164_2.png) [@QbaF](https://discourse.nodered.org/u/QbaF)
#### Post date: [7 March 2020 16:38 UTC](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697/22 "2020-03-07T16:38:11Z")

</div>

> [@zenofmud](#):
>
> I assume you ment this for me.

No, TotallyInformation says:

> You would need to look up the issue I raised

But thank you. Especially for that link you gave (also because in that link is now the link I was asking for). Rest about this work around was completely clear and I appreciate it.

---

<div class="post-metadata">

### Author: ![QbaF](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/qbaf/32/51164_2.png) [@QbaF](https://discourse.nodered.org/u/QbaF)
#### Post date: [7 March 2020 16:50 UTC](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697/23 "2020-03-07T16:50:47Z")

</div>

> [@QbaF](#):
>
> > [@QbaF](#):
> >
> > both cases (good and wrong) there are more than 3 decimal places.
> 
> You would need to look up the issue I raised

I saw it. My question is why 3+ digital point is issue only in same (minor) cases?

---

<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 16:52 UTC](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697/24 "2020-03-07T16:52:33Z")

</div>

> [@QbaF](#):
>
> Could You please send link to the issue mentioned. [I can see only two issues](https://github.com/TotallyInformation/node-red-contrib-moment/issues/28) connected with `moment` but no one is yours.

Yes, sorry, I had a memory failure. It is actually the parser that is wrong not MomentJS. The last time I tested Moment, it could handle up to 9dp's I think.

> <https://github.com/gr2m/moment-parseformat/issues/96>
>
> The following code:
> 
> \`\`\`javascript
> var moment = require('moment')
> var parseF…ormat = require('moment-parseformat')
> 
> var dp6 = "2019-05-25T15:30:42.526058+00:00"
> var dp5 = "2019-05-25T15:30:42.52605+00:00"
> 
> var long6dp = moment(dp6)
> var long5dp = moment(dp5)
> 
> var fmt6dp = parseFormat(dp6,{preferredOrder: {'/': 'DMY', '.': 'DMY', '-': 'YMD'}})
> var fmt5dp = parseFormat(dp5,{preferredOrder: {'/': 'DMY', '.': 'DMY', '-': 'YMD'}})
> 
> var fmt6dpMoment = moment(dp6, fmt6dp)
> var fmt5dpMoment = moment(dp5, fmt5dp)
> 
> console.log( 'long6dp', long6dp.format() )
> console.log( 'long5dp', long5dp.format() )
> console.log( 'fmt6dp parseFormat', fmt6dp )
> console.log( 'fmt5dp parseFormat', fmt5dp )
> console.log( 'fmt6dpMoment', fmt6dpMoment.format() )
> console.log( 'fmt5dpMoment', fmt5dpMoment.format() )
> \`\`\`
> 
> Produces the following output:
> 
> \`\`\`
> long6dp 2019-05-25T16:30:42+01:00
> long5dp 2019-05-25T16:30:42+01:00
> fmt6dp parseFormat YYYY-MM-DDTHH:mm:ss.SSSDDDZ
> fmt5dp parseFormat YYYY-MM-DDTHH:mm:ss.SSSDDZ
> fmt6dpMoment 2019-02-27T15:30:42+00:00
> fmt5dpMoment 2019-05-05T16:30:42+01:00
> \`\`\`
> 
> As you can see, anything beyond 3DP on the seconds value results in "D" specifications on the end of the fractional seconds which is clearly incorrect and produces uncertain output from moment.
> 
> Reported to me in the following issue:
> 
> https://github.com/TotallyInformation/node-red-contrib-moment/issues/24

---

<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 16:53 UTC](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697/25 "2020-03-07T16:53:26Z")

</div>

> [@QbaF](#):
>
> My question is why 3+ digital point is issue only in same (minor) cases?

It is the way that the parser uses a regular expression. It ends up with an incorrect date being used.

---

<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 2020 16:53 UTC](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697/26 "2020-05-06T16:53:28Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/node-moment-output-format-calendar-different-results/22697.md?page=1)
