# DateTime error (Daylight Savings Time)?

**URL:** <https://community.homey.app/t/datetime-error-daylight-savings-time/78126>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [March 20, 2023, 6:37pm UTC](https://community.homey.app/t/datetime-error-daylight-savings-time/78126 "2023-03-20T18:37:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat\_M](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pat_m/32/56295_2.png) [@Pat\_M](https://community.homey.app/u/Pat_M)\
**Post date:** [March 20, 2023, 6:37pm UTC](https://community.homey.app/t/datetime-error-daylight-savings-time/78126/1 "2023-03-20T18:37:42Z")

</div>

Hi!

I use BetterLogic (great app btw) to get $timenow$. It’s correct in Swedish time adjusted to DST.  
I try \<const d = new Date();\> in Homey Script. It returns 1 hour wrong. I run that code in my browser ([W3Schools Tryit Editor](https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_obj)) and it returns correctly.

How can I get Homey to return the correct time? This is vital for me.

Many thanks!

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 20, 2023, 7:32pm UTC](https://community.homey.app/t/datetime-error-daylight-savings-time/78126/2 "2023-03-20T19:32:51Z")

</div>

What does the humanTime say here?:  
[https://tools.developer.homey.app/tools/system](https://tools.developer.homey.app/tools/system)

A way to force the right timezone is to temporary move your location to another timezone and move it back after a while  
( …More \> Settings \> Location)

Or it is the issue Homey uses UTC everywhere.  
Script (partly in dutch):

> [@Actuele tijd weergeven inclusief secondes](https://community.homey.app/t/actuele-tijd-weergeven-inclusief-secondes/75247/2):
>
> Probeer dit script eens: return getCurrentTime("nl-NL","Europe/Amsterdam"); function getCurrentTime(locale, timezone){ let date = new Date(); return date.toLocaleString(locale,{timeZone: timezone }); //return date.toLocaleTimeString(locale,{timeZone: timezone }); //return date.toLocaleDateString(locale,{timeZone: timezone }); } Ik heb het script nog even aangepast. Hij zal nu “datum+tijd” teruggeven, maar je kan ook alleen de tijd of alleen de datum ter…

---

<div class="post-metadata">

**Author:** ![Pat\_M](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pat_m/32/56295_2.png) [@Pat\_M](https://community.homey.app/u/Pat_M)\
**Post date:** [March 21, 2023, 11:56am UTC](https://community.homey.app/t/datetime-error-daylight-savings-time/78126/3 "2023-03-21T11:56:10Z")

</div>

Hi!

| dateHuman | Tuesday 21st March 2023 12:54:00 |
| --- | --- |
| dateDst | false |

Both are correct “there” but not from the Homey Script console, where I need it. Weird! I will brush off my dutch now and read your thread! 😉

Many thanks!

---

<div class="post-metadata">

**Author:** ![Pat\_M](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pat_m/32/56295_2.png) [@Pat\_M](https://community.homey.app/u/Pat_M)\
**Post date:** [March 21, 2023, 12:43pm UTC](https://community.homey.app/t/datetime-error-daylight-savings-time/78126/4 "2023-03-21T12:43:51Z")

</div>

> [@Actuele tijd weergeven inclusief secondes](https://community.homey.app/t/actuele-tijd-weergeven-inclusief-secondes/75247/2):
>
> ```auto
> return getCurrentTime("nl-NL","Europe/Amsterdam");
> 
> function getCurrentTime(locale, timezone){
> let date = new Date();
> return date.toLocaleString(locale,{timeZone: timezone });        
> //return date.toLocaleTimeString(locale,{timeZone: timezone });        
> //return date.toLocaleDateString(locale,{timeZone: timezone });        
> }
> 
> ```

Thank you, this worked!!!
