# Working with Date and Time

**URL:** <https://discourse.nodered.org/t/working-with-date-and-time/1616>\
**Category:** General\
**Created:** [16 July 2018 18:21 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616 "2018-07-16T18:21:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dedynobre](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dedynobre/32/950_2.png) [@dedynobre](https://discourse.nodered.org/u/dedynobre)\
**Post date:** [16 July 2018 18:21 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/1 "2018-07-16T18:21:01Z")

</div>

Hi!

I have a field in the dashboard called Time League and Other Field called Time Off, both of type time.

You can compare if the clock time is the same as the Time or Time node Turns it off to perform an action.

I've seen components that turn on and off at pre-set times.  
I wanted to leave those values on the dashboard to have more freedom of change.

---

<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:** [16 July 2018 20:30 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/2 "2018-07-16T20:30:30Z")

</div>

I am not sure what your question is, can you try and ask it again please?

---

<div class="post-metadata">

**Author:** ![dedynobre](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dedynobre/32/950_2.png) [@dedynobre](https://discourse.nodered.org/u/dedynobre)\
**Post date:** [16 July 2018 23:47 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/3 "2018-07-16T23:47:35Z")

</div>

OK, let's go!

I have one the following component:

[{"id":"7f0ab78e.075048","type":"ui\_text\_input","z":"6dab2b1d.f7d284","name":"","label":"","group":"d0992582.f6b428","order":0,"width":0,"height":0,"passthru":true,"mode":"time","delay":300,"topic":"","x":1360,"y":860,"wires":[[]]},{"id":"d0992582.f6b428","type":"ui\_group","z":"","name":"Componentes para Teste","tab":"ff7880d6.482cd","order":2,"disp":true,"width":"6","collapse":false},{"id":"ff7880d6.482cd","type":"ui\_tab","z":"","name":"Testes","icon":"dashboard","order":5}]

I'll come in with some schedule on it.

I would like the current schedule to be the same as the configured schedule would perform an action.

---

<div class="post-metadata">

**Author:** ![machadotiago](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/machadotiago/32/23776_2.png) [@machadotiago](https://discourse.nodered.org/u/machadotiago)\
**Post date:** [17 July 2018 15:02 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/4 "2018-07-17T15:02:21Z")

</div>

I'm also not sure if I understood correctly what is your question.  
As far as I understood you will receive a timestamp on a payload into your "text input" node right? And you don't want that the "text input" node assumes the received payload, right?  
If this is the case you can add a "change" node that will remove the payload of the message

Try it:  
`[{"id":"4564a8ae.809a18","type":"ui_text_input","z":"ee93a7ae.bcaa68","name":"","label":"","group":"40d12c28.d68944","order":0,"width":0,"height":0,"passthru":false,"mode":"time","delay":300,"topic":"","x":660,"y":180,"wires":[[]]},{"id":"5bf5e48e.db6a8c","type":"inject","z":"ee93a7ae.bcaa68","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":180,"wires":[["34aed07d.3ab21"]]},{"id":"34aed07d.3ab21","type":"change","z":"ee93a7ae.bcaa68","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":180,"wires":[["4564a8ae.809a18"]]},{"id":"40d12c28.d68944","type":"ui_group","z":"","name":"Componentes para Teste","tab":"1f2f9754.6dccf9","order":2,"disp":true,"width":"6","collapse":false},{"id":"1f2f9754.6dccf9","type":"ui_tab","z":"","name":"Testes","icon":"dashboard","order":5}]`

Obs: também podemos conversar em português se você se sentir mais confortável assim 🙂

---

<div class="post-metadata">

**Author:** ![dedynobre](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dedynobre/32/950_2.png) [@dedynobre](https://discourse.nodered.org/u/dedynobre)\
**Post date:** [17 July 2018 15:41 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/5 "2018-07-17T15:41:34Z")

</div>

Ufa @machadotiago agora vai melhorar bastante.  
O tradutor tá quebrando minhas pernas.

---

<div class="post-metadata">

**Author:** ![dedynobre](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dedynobre/32/950_2.png) [@dedynobre](https://discourse.nodered.org/u/dedynobre)\
**Post date:** [17 July 2018 15:45 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/6 "2018-07-17T15:45:22Z")

</div>

Então, deixa eu explicar em português que vai ser mais fácil.

Eu tenho o time input no meu dashboard que irei setar o meu tempo, por exemplo, para ligar a TV.

E gostaria que sempre que chegar no horário configurado no input time eu iria executar uma ação.  
Como uso o Home Assistant, sempre que chegar nesse horário ele irá chamar um serviço do Home Assistant.

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [17 July 2018 16:34 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/7 "2018-07-17T16:34:34Z")

</div>

Boa tarde dedynobre

If you wanted to set the timing dinamically check for schedex [https://www.npmjs.com/package/node-red-contrib-schedex](https://www.npmjs.com/package/node-red-contrib-schedex)

If you look over the forum will find there is another discussion about this topic.

Regards

---

<div class="post-metadata">

**Author:** ![dedynobre](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dedynobre/32/950_2.png) [@dedynobre](https://discourse.nodered.org/u/dedynobre)\
**Post date:** [17 July 2018 19:36 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/8 "2018-07-17T19:36:43Z")

</div>

OK,

fiz o seguinte:

[{"id":"a90d4d3d.a505c","type":"ui\_text\_input","z":"3078e521.688d6a","name":"","label":"","group":"dde7b5.6f265848","order":0,"width":0,"height":0,"passthru":false,"mode":"time","delay":300,"topic":"","x":420,"y":180,"wires":[["45c862b4.64e9ec"]]},{"id":"b9e9a1e7.b2468","type":"inject","z":"3078e521.688d6a","name":"","topic":"","payload":"liga","payloadType":"global","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":240,"wires":[["7e57743d.63f20c"]]},{"id":"5dde8ec9.97193","type":"debug","z":"3078e521.688d6a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":950,"y":240,"wires":[]},{"id":"f9adc51c.d30c38","type":"schedex","z":"3078e521.688d6a","name":"","suspended":false,"lat":"","lon":"","ontime":"00:00","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"goldenHour","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":670,"y":240,"wires":[["5dde8ec9.97193"]]},{"id":"7e57743d.63f20c","type":"change","z":"3078e521.688d6a","name":"","rules":[{"t":"set","p":"payload.ontime","pt":"msg","to":"liga","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":240,"wires":[["f9adc51c.d30c38"]]},{"id":"45c862b4.64e9ec","type":"change","z":"3078e521.688d6a","name":"","rules":[{"t":"set","p":"liga","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":180,"wires":[[]]},{"id":"dde7b5.6f265848","type":"ui\_group","z":"","name":"Componentes para Teste","tab":"c4d69d67.5f1c1","order":2,"disp":true,"width":"6","collapse":false},{"id":"c4d69d67.5f1c1","type":"ui\_tab","z":"","name":"Testes","icon":"dashboard","order":5}]

Mas nao deu certo.

Eu passei msg.payload.time com o valor do input time mas da erro.

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [17 July 2018 20:52 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/9 "2018-07-17T20:52:16Z")

</div>

Boa noite dedy

Please read a bit the docu, you will find how to set all options, as example test this:

```auto
[{"id":"6b211f47.a1146","type":"debug","z":"45bdc7c3.85f6b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":889,"y":214,"wires":[]},{"id":"4e05f7de.2e01f8","type":"schedex","z":"45bdc7c3.85f6b8","name":"","suspended":false,"lat":"","lon":"","ontime":"00:00","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"goldenHour","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":609,"y":214,"wires":[["6b211f47.a1146"]]},{"id":"a1757a9c.6dc8a8","type":"ui_dropdown","z":"45bdc7c3.85f6b8","name":"","label":"ON","place":"Select option","group":"4a87f70d.f8be18","order":0,"width":0,"height":0,"passthru":true,"options":[{"label":"1:00","value":"ontime 1:00","type":"str"},{"label":"2:00","value":"ontime 2:00","type":"str"}],"payload":"","topic":"","x":315,"y":163,"wires":[["4e05f7de.2e01f8"]]},{"id":"b3b357f7.a05f88","type":"ui_dropdown","z":"45bdc7c3.85f6b8","name":"","label":"OFF","place":"Select option","group":"4a87f70d.f8be18","order":0,"width":0,"height":0,"passthru":true,"options":[{"label":"3:00","value":"offtime 3:00","type":"str"},{"label":"4:00","value":"offtime 4:00","type":"str"}],"payload":"","topic":"","x":309,"y":257,"wires":[["4e05f7de.2e01f8"]]},{"id":"4a87f70d.f8be18","type":"ui_group","z":"","name":"Componentes para Teste","tab":"8832090d.208368","order":2,"disp":true,"width":"6","collapse":false},{"id":"8832090d.208368","type":"ui_tab","z":"","name":"Testes","icon":"dashboard","order":5}]
```

---

<div class="post-metadata">

**Author:** ![dedynobre](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dedynobre/32/950_2.png) [@dedynobre](https://discourse.nodered.org/u/dedynobre)\
**Post date:** [17 July 2018 21:45 UTC](https://discourse.nodered.org/t/working-with-date-and-time/1616/10 "2018-07-17T21:45:14Z")

</div>

Olá @davidcgu,

O exemplo que voce enviou funcionou conforme gostaria.

Eu li o documento só que não consegui passar os parametros corretamente.

Muito obrigado pela ajuda.
