# A question about "Simpletime"

**URL:** <https://discourse.nodered.org/t/a-question-about-simpletime/36328>\
**Category:** General\
**Created:** [22 November 2020 12:16 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328 "2020-11-22T12:16:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [22 November 2020 12:16 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/1 "2020-11-22T12:16:36Z")

</div>

Hi,  
last year I used the "Simpletime" node. I remember using the following code:

```auto
if(msg.mymonthn>=4||(msg.mymonthn<=10&&msg.mydom<27)){//adjust based on Daylight savings time
    msg.myhour+=1;
}
else{
    msg.myhour-=1;
}

```

I am trying to recreate it at the moment, but having issues. The node has changed. Now I want to know if the node uses the computer time?

I remember having to adjust for DST, but now I don't (testing locally). Also I remember when I added an hour it actually took away an hour. Can anyone help with clarifying as the documentation doesn't say where the source of time is from.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [22 November 2020 13:01 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/2 "2020-11-22T13:01:59Z")

</div>

Simpletime uses, and has always used `Date()` to determine the base time, on which the calculations are based.  
Which in turn uses the user's local (browser's) timezone.  
No changes have been made to this since the node was first written, so it's likely that at some stage your system has changed to respect your current timezone. Is that likely?

---

<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:** [22 November 2020 13:39 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/3 "2020-11-22T13:39:43Z")

</div>

> [@DillonW](#):
>
> I remember having to adjust for DST, but now I don't

You shouldn't have to provided the timezone is correctly set on the node-red machine, and the time is set correctly.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [22 November 2020 15:49 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/4 "2020-11-22T15:49:24Z")

</div>

> [@DillonW](#):
>
> I remember using the following code:
> 
> ```auto
> if(msg.mymonthn>=4||(msg.mymonthn<=10&&msg.mydom<27)){//adjust based on Daylight savings time
> msg.myhour+=1;
> }
> else{
> msg.myhour-=1;
> }
> 
> ```

I don't think that code will actually work for at least 2 reasons anyway;

1. The values from Simpletime are all strings, not numbers, so if the hour was `15`, and the calculation was `msg.myhour+=1;` wouldn't the resulting value be `151`?
2. Again if the hour was `15`, and you added an hour from `msg.myhour` (`+=1`) the result would be `16`, whilst subtracting an hour from `msg.myhour` (`-=1`) would result in `14`.  
Meaning that there is a 2hr difference between GMT & IST(BST) which is incorrect.

---

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [22 November 2020 16:03 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/5 "2020-11-22T16:03:04Z")

</div>

Thats the thing. they are strings but I remeber when I tested it I had it working last year. Maybe I'm wrong.

I understand the logic of addition and subtracting, just for some reason when I tested it I remember it working.

---

<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:** [22 November 2020 16:10 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/6 "2020-11-22T16:10:24Z")

</div>

Are you getting the wrong times out of the node? It should take DST into account.

---

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [22 November 2020 16:20 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/7 "2020-11-22T16:20:01Z")

</div>

Not now. But when I tested it last year I was using IBM's version of node-red(hosted in London) and I remember having to adjust for DST. At the moment I'm not having that issue.

---

<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:** [22 November 2020 16:33 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/8 "2020-11-22T16:33:22Z")

</div>

The system probably had the wrong timezone configured.

---

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [22 November 2020 18:36 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/9 "2020-11-22T18:36:55Z")

</div>

Thanks for the explanation and clarification.

---

<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:** [21 January 2021 18:37 UTC](https://discourse.nodered.org/t/a-question-about-simpletime/36328/10 "2021-01-21T18:37:00Z")

</div>

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