# HomeyScript and system clock

**URL:** <https://community.homey.app/t/homeyscript-and-system-clock/105446>\
**Category:** Questions & Help\
**Created:** [March 3, 2024, 5:14pm UTC](https://community.homey.app/t/homeyscript-and-system-clock/105446 "2024-03-03T17:14:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Imilender](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/imilender/32/88993_2.png) [@Imilender](https://community.homey.app/u/Imilender)\
**Post date:** [March 3, 2024, 5:14pm UTC](https://community.homey.app/t/homeyscript-and-system-clock/105446/1 "2024-03-03T17:14:00Z")

</div>

Hi there,

I’m trying to setup a Homeyscript that would chat what hour it is and then perform certain action depending on the hour. If I run

```auto
const now = new Date();
const currentHour = now.getHours();

```

I get the UTC current hour but not my local hour here in Finland.

I’ve tried following:

```auto
//set desiredLocale to Finland

const desiredLocale = 'fi-FI';

// Create a new Date object

const now = new Date();

// Get the time string in the specified locale

const timeInLocale = now.toLocaleTimeString(desiredLocale);

```

But the timeInLocale still returns the UTC time?

When I run the code in javascript emulator it works fine? Any Idea why HomeyScript doesn’t localize the time for me?

Thanks

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 3, 2024, 6:07pm UTC](https://community.homey.app/t/homeyscript-and-system-clock/105446/2 "2024-03-03T18:07:19Z")

</div>

Use the Better Logic Library app for local datetimes.

---

<div class="post-metadata">

**Author:** ![Imilender](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/imilender/32/88993_2.png) [@Imilender](https://community.homey.app/u/Imilender)\
**Post date:** [March 4, 2024, 8:41am UTC](https://community.homey.app/t/homeyscript-and-system-clock/105446/3 "2024-03-04T08:41:32Z")

</div>

Thanks Arie, but that’s not really what I was looking for. The solution I want to build seems to need the use of HomeyScript, but I would need to get the local time in the homeyScript, but for some reason the HomeyScript doesn’t return the locale.

Or course I can always add the +2 or +3 depending on if it is summer time or winter time to the time returned by Date(), but the problem is that then I need to update that time always when the Daylight sving starts/ends… For that reason I’d like to get the localization to work, and not have to worry about “wrong timezone”.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 4, 2024, 8:53am UTC](https://community.homey.app/t/homeyscript-and-system-clock/105446/4 "2024-03-04T08:53:40Z")

</div>

> [@Imilender](#):
>
> But the timeInLocale still returns the UTC time?

`toLocaleTimeString()` by itself only formats a time string according to the current locale, not the current timezone. For that, [see this post](https://community.homey.app/t/local-time-in-homeyscript/33338/35).

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [March 5, 2024, 6:32am UTC](https://community.homey.app/t/homeyscript-and-system-clock/105446/6 "2024-03-05T06:32:30Z")

</div>

You can call the date function in HomeyScript through the api from BLL.
