# Performance quesrion re date and time in lots of flows

**URL:** <https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504>\
**Category:** General\
**Created:** [27 September 2018 15:22 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504 "2018-09-27T15:22:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [27 September 2018 15:22 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/1 "2018-09-27T15:22:49Z")

</div>

Guys,

If i end up with lots of lfows that are accessing Date and or time for functions and for logging etc - am i better off having a single Node on a flow that sets a global date and time object (in my desirred format) and then access that object from my flows when/where needed, or am i better off using and accessing the date and time in each flow (either through the native JS functions in a function node) or through the moment node ? Or does it not matter in the overall scheme of things.

I am running on a VM on a HP Microserver under Ubuntu 18.04

Craig

---

<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:** [27 September 2018 22:09 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/2 "2018-09-27T22:09:22Z")

</div>

The main issue here, I think, is not the performance but actually whether you need a SINGLE date/time value - e.g. is your flow time-critical enough to force you to use a single value throughout.

The second question is whether you have a single flow or many. If only a single flow, then simply add a timestamp to the `msg` and let it flow through. If you have many flows, then you will want to put your single value into a variable but you will have to watch out for timing issues.

If you are using a simple JS date/time value, I don't believe you will really notice any performance issues unless you are generating many thousands of values.

Things will be slightly different if you are using moment since it is rather more heavyweight. I still think you would struggle to notice any performance issues but I guess if your flows are REALLY big, you might.

Bottom line: Do you want a single, universal date/time value or not? Is your processing likely to be sensitive to a second or so difference in values?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [28 September 2018 07:57 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/3 "2018-09-28T07:57:51Z")

</div>

Nope not time critical like that - there will be lots of flows that will use the time for logging or making decisions etc - but if i was to updated a global memory variable every 10 seconds for instance that would be good enough in terms of logging to files etc.

Craig

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [28 September 2018 16:22 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/4 "2018-09-28T16:22:44Z")

</div>

I can't imagine that reading from global context is any faster than asking JS to give you the current date, so I would probably skip the overhead of having a flow just to keep a timestamp in memory.

Where timestamps get tedious is in the formatting, say for logging or display purposes. You may want to look at [this simpletime node](https://flows.nodered.org/node/node-red-contrib-simpletime) which provides many useful versions of components of the current timestamp for you.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [29 September 2018 07:38 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/5 "2018-09-29T07:38:21Z")

</div>

Thanks Steve - will do

Craig

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [29 September 2018 07:59 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/6 "2018-09-29T07:59:05Z")

</div>

Which timestamp format do you need?  
Something like following is quite easy to build with js or jsonata:

```auto
YYYY-MM-DD_hh:mm:ss

```

---

<div class="post-metadata">

**Author:** ![moebius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/moebius/32/2872_2.png) [@moebius](https://discourse.nodered.org/u/moebius)\
**Post date:** [29 September 2018 09:45 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/7 "2018-09-29T09:45:54Z")

</div>

Is there any special reason, why you dont try it out?

It should be pretty easy to simulate the desired behavior - maybe with a rapid prototyping graphical tool?

oh wait... 🙂

---

<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:** [29 September 2018 15:31 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/8 "2018-09-29T15:31:17Z")

</div>

> [@cflurin](#):
>
> YYYY-MM-DD\_hh:mm:ss

Much better to use ISO/Internet time format:

yyyy-mm-ddThh:mm:ssZ

[https://tools.ietf.org/search/rfc3339](https://tools.ietf.org/search/rfc3339)

This is parsable and understood widely.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [3 October 2018 23:49 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/9 "2018-10-03T23:49:20Z")

</div>

Yep thats the format i am using !

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [3 October 2018 23:50 UTC](https://discourse.nodered.org/t/performance-quesrion-re-date-and-time-in-lots-of-flows/3504/10 "2018-10-03T23:50:12Z")

</div>

😃😃😃

Yep already have it running - just wondering if i was going to run over a cliff at some point in the future so doing a sanity check !

Craig
