# If statement with strings, time

**URL:** <https://discourse.nodered.org/t/if-statement-with-strings-time/38036>\
**Category:** General\
**Created:** [26 December 2020 16:06 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036 "2020-12-26T16:06:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![slieber007](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@slieber007](https://discourse.nodered.org/u/slieber007)\
**Post date:** [26 December 2020 16:06 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/1 "2020-12-26T16:06:04Z")

</div>

Hello, first of all... i have 0.1% knowledge of node red.  
for school I have to make an automated system that sends every morning on the time when the sun comes up an email trough IFTTT of the temperature from our nearest city. (openweathermap)

Right now I have a system that can send the temperature of the nearest city to my email trough IFTTT.  
Now i am trying for 3 days straight to get the time from the sunrise to activate the system... but nothing works.  
i found something to convert the sunrise to a string named msg.payload.sun  
and i have the string of my local time msg.payload

Is it now possible the use a if functions when the 2 msg's are the same it triggers the system?

thx!

---

<div class="post-metadata">

**Author:** ![slieber007](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@slieber007](https://discourse.nodered.org/u/slieber007)\
**Post date:** [26 December 2020 16:08 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/3 "2020-12-26T16:08:51Z")

</div>

> **[Paste ofCode](https://paste.ofcode.org/3PScitTXtc4HL3H96aP2pa)**

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 December 2020 16:17 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/4 "2020-12-26T16:17:15Z")

</div>

Hi there is no need to post code to external service, just paste it between backticks

`````  
`like this`  
`````

As for your issue, there are several nodes which can tell you when it is sunrise time e.g...  
node-red-contrib-cron-plus

 ![cron-plus-map](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0ff8f6cf459cbc1b0875a37adcf8cd86f07018c.gif)

for sending emails there is `node-red-node-email`

NOTE: I dont use IFTTT (so cant help) - mostly due to the fact I can do pretty much everything i need to without it & the [recent changes](https://www.droid-life.com/2020/09/10/ifttt-moves-to-subscription-model-with-introduction-of-ifttt-pro/) to their product.

---

<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:** [26 December 2020 16:24 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/5 "2020-12-26T16:24:46Z")

</div>

> [@slieber007](#):
>
> i have 0.1% knowledge of node red.

Start by spending an hour watching the [node-red essentials](https://www.youtube.com/watch?v=ksGeUD26Mw0) videos, it will be time well spent.

---

<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:** [26 December 2020 16:54 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/6 "2020-12-26T16:54:29Z")

</div>

Openweathermap returns the sunrise as a timestamp in seconds, while JS and moment use milliseconds. You will need to multiple the returned sunrise timestamp by 1000.

---

<div class="post-metadata">

**Author:** ![slieber007](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@slieber007](https://discourse.nodered.org/u/slieber007)\
**Post date:** [27 December 2020 09:26 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/7 "2020-12-27T09:26:00Z")

</div>

wow.... that node just fixed everything thank you so much!!!!!!!!!

---

<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:** [10 January 2021 09:26 UTC](https://discourse.nodered.org/t/if-statement-with-strings-time/38036/8 "2021-01-10T09:26:03Z")

</div>

Closed on 10 January 2021 09:26 UTC

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