# Inject time change (hour)

**URL:** <https://discourse.nodered.org/t/inject-time-change-hour/41171>\
**Category:** General\
**Created:** [17 February 2021 15:18 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171 "2021-02-17T15:18:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benja](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@Benja](https://discourse.nodered.org/u/Benja)\
**Post date:** [17 February 2021 15:18 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/1 "2021-02-17T15:18:07Z")

</div>

Hi, I need to create an inject when the hour changes.  
Some help please!

Is there a way to do that?

---

<div class="post-metadata">

**Author:** ![ceysa75](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ceysa75/32/31340_2.png) [@ceysa75](https://discourse.nodered.org/u/ceysa75)\
**Post date:** [17 February 2021 15:27 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/2 "2021-02-17T15:27:52Z")

</div>

Use node-red-contrib-cron-plus for that with the expression: At minute 0 (0 \* \* \* \*)

---

<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:** [17 February 2021 16:07 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/3 "2021-02-17T16:07:01Z")

</div>

The standard inject node set to interval between times, and set to every 60 minutes, will inject on the hour.  
e.g.

```auto
[{"id":"3f35d274.99189e","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":680,"y":1840,"wires":[]},{"id":"4bc4cca2.df47e4","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"0 0-23 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":1880,"wires":[["3f35d274.99189e"]]}]

```

---

<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:** [17 February 2021 16:36 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/4 "2021-02-17T16:36:29Z")

</div>

Though it is not reliable if your system is something like a Pi that does not have a hardware RTC, if the system clock does not synchronise before node-red is started, as can happen when using WiFi for example. Cron plus does cope with this situation.

---

<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:** [17 February 2021 16:49 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/5 "2021-02-17T16:49:43Z")

</div>

If unreliable then maybe it should be noted in the node info help.

---

<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:** [17 February 2021 16:56 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/6 "2021-02-17T16:56:55Z")

</div>

There is an open issue, but it is difficult to fix I think. [inject node specific time - triggers late · Issue #1839 · node-red/node-red · GitHub](https://github.com/node-red/node-red/issues/1839)

---

<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:** [17 February 2021 17:08 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/7 "2021-02-17T17:08:20Z")

</div>

There appears to a work around to make node-red wait till time sync.

> [@](#):
>
> In the latest `nodered.service` file there is a line you can uncomment to make it wait until it has a timesync... we don't enable it by default for obvious reasons... (like if you aren't on a network and never get time sync it won't ever start)...

I have never suffered with any issues with timing, as my node-red delays restart till operating system has been started and running.

---

<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:** [17 February 2021 19:33 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/9 "2021-02-17T19:33:03Z")

</div>

> [@E1cid](#):
>
> There appears to a work around to make node-red wait till time sync.

You should note, however, that this can make the startup completely hang if the Internet is down. There was a longish thread about this a while ago.

---

<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:** [17 February 2021 20:01 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/10 "2021-02-17T20:01:10Z")

</div>

> [@E1cid](#):
>
> ... (like if you aren't on a network and never get time sync it won't ever start)...

Yes i read that in the quote i posted.

---

<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:** [3 March 2021 20:01 UTC](https://discourse.nodered.org/t/inject-time-change-hour/41171/11 "2021-03-03T20:01:43Z")

</div>

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