# How to get user's timezone

**URL:** https://community.thunkable.com/t/how-to-get-users-timezone/1224457
**Category:** Questions about Thunkable X
**Tags:** clock, time\_picker
**Created:** [April 14, 2021, 10:08pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457 "2021-04-14T22:08:47Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![maptheunknown](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@maptheunknown](https://community.thunkable.com/u/maptheunknown)
#### Post date: [April 14, 2021, 10:08pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/1 "2021-04-14T22:08:47Z")

</div>

Anyone knows how to get the user’s timezone?

I need it so I can schedule some jobs and reminders according to the user’s timezone location. I can ask users to manually enter their timezone but I would rather not do that extra step for users and just get their timezone automatically from their phones.

Also I was hoping to find a more local solution that doesn’t need an api call to a world clock api.

Thnaks in advanced!

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [April 14, 2021, 11:36pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/2 "2021-04-14T23:36:32Z")

</div>

I’m not sure but it occurred to me that you could get the device hour from Thunkable and then compare it to [GMT](https://www.timeanddate.com/time/zones/gmt) via an API call and then based on the difference, figure out their timezone. It wouldn’t be perfect, though, because for example here in California we have Daylight Savings which alters the time by an hour.

---

<div class="post-metadata">

### Author: ![maptheunknown](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@maptheunknown](https://community.thunkable.com/u/maptheunknown)
#### Post date: [April 15, 2021, 1:00am UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/3 "2021-04-15T01:00:04Z")

</div>

Hey thanks for the suggestion. That’s exactly what I’m doing now but it’s kinda messy Or prone to bugs due to daylight saving time. Also I was hoping to find a more local solution that doesn’t need an api call to a world clock api.

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [April 15, 2021, 5:16am UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/4 "2021-04-15T05:16:50Z")

</div>

Maybe you can get the user’s coordinates using the Location Sensor component, and then put them in [this](https://developers.google.com/maps/documentation/timezone/overview) API, and Google will send back the timezone.

---

<div class="post-metadata">

### Author: ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)
#### Post date: [April 15, 2021, 6:40am UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/5 "2021-04-15T06:40:38Z")

</div>

Hi there,

I would also recommend using an API! You can check out this tutorial for my [Reverse Geocoding App - Get Location from Latitude/Longitude](https://community.thunkable.com/t/reverse-geocoding-app-get-location-from-latitude-longitude/82343) that uses the OpenCageData API. This tutorial will return the user’s country, but you can also get the user’s timezone.

This will be in the format:

```auto
"timezone" : {
               "name" : "America/Sao_Paulo",
               "now_in_dst" : 0,
               "offset_sec" : -10800,
               "offset_string" : "-0300",
               "short_name" : "BRT"
            },

```

Here is their description of the timezone property:

contains the keys name , now\_in\_dst , offset\_sec , offset\_string , short\_name.  
When the coordinates are in a country the name will be of the form Continent/City, the format used by [tz database](https://en.wikipedia.org/wiki/Tz_database) on \*nix systems, for example Europe/Lisbon. When the coordinates are not in a country (for example in an ocean) the format will be an offset to/from GMT, for example GMT+2.  
Learn more about timezones and how they are typically represented on \*nix based systems [over on Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

I got this information from this web page: [OpenCage Geocoding API Documentation](https://opencagedata.com/api)

Hope that helps!

---

<div class="post-metadata">

### Author: ![maptheunknown](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@maptheunknown](https://community.thunkable.com/u/maptheunknown)
#### Post date: [April 15, 2021, 3:20pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/6 "2021-04-15T15:20:56Z")

</div>

Thanks for the suggestion guys!

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [April 16, 2021, 11:18am UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/7 "2021-04-16T11:18:53Z")

</div>

I found the easiest way to get the timezone is by using the date() object of the vanilla JS and all what you need is the web viewer instead of web API calls.

Get the number of seconds since 1970 and multiply it by a 1000 and create a new date object from it.

Then use the newDateObject.toLocaleString(“en-US”, {timeZoneName: “short”})

This will display the time zone along with the date in a human readable format.

---

<div class="post-metadata">

### Author: ![a.sa.pellaiahj3c](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@a.sa.pellaiahj3c](https://community.thunkable.com/u/a.sa.pellaiahj3c)
#### Post date: [May 5, 2021, 5:10pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/8 "2021-05-05T17:10:11Z")

</div>

Hi, it sounds good could you explain it further? How do you use javascript in Thunkable? Thanks

---

<div class="post-metadata">

### Author: ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)
#### Post date: [May 5, 2021, 5:13pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/9 "2021-05-05T17:13:33Z")

</div>

I am not good with APIs or databases. However, I don’t think there is any way you could use javascript in thunkable.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [May 5, 2021, 5:17pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/10 "2021-05-05T17:17:24Z")

</div>

YES, there is a way to use JavaScript in Thunkable. This is done using the Data Viewer extension to receive data from Thunkable and to send data to Thunkable.

[Web Viewer Extension Example](https://github.com/thunkable/webviewer-extension)

This should show you how Thunkable interact with web pages.

---

<div class="post-metadata">

### Author: ![a.sa.pellaiahj3c](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@a.sa.pellaiahj3c](https://community.thunkable.com/u/a.sa.pellaiahj3c)
#### Post date: [May 5, 2021, 5:26pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/11 "2021-05-05T17:26:49Z")

</div>

Sorry I am confused should one use the Data or Web viewer? Where should one upload the javascript file?

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [May 6, 2021, 11:23am UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/12 "2021-05-06T11:23:44Z")

</div>

> [@a.sa.pellaiahj3c](#):
>
> sounds good could you explain it further?

> [@human](#):
>
> I am not good with APIs or databases.

@a.sa.pellaiahj3c & @human APIs are definitely a big topic and can be tricky to understand if it’s your first time seeing them. Thankfully there are lots of great tutorials, both here and on YouTube, that explain this topic.

Here’s a great one from @tatiang to get you started:

> [@API JSON Tutorial (Video)](https://community.thunkable.com/t/api-json-tutorial-video/1140575):
>
> Using APIs in Thunkable and understanding how to parse JSON to get certain data from the API response is both a popular and a difficult aspect of using Thunkable. It’s not so much difficult because of Thunkable but because every API url format is different, every API documentation is different, every JSON response is different, etc. In this video, I spend a lot of time talking you through some best practices. It’s not a quick tutorial because if you rush through setting up an API in Thunkable, …

---

<div class="post-metadata">

### Author: ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)
#### Post date: [May 6, 2021, 1:23pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/13 "2021-05-06T13:23:33Z")

</div>

Okay, I’ll check it out!

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [May 6, 2021, 2:25pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/14 "2021-05-06T14:25:01Z")

</div>

@a.sa.pellaiahj3c  
@human  
@domhnallohanlon  
Please see this example of using JavaScript file to get the Date and Time and the Time Zone.  
[https://x.thunkable.com/projectPage/6093d4a8b86e4b01ee61b244](https://x.thunkable.com/projectPage/6093d4a8b86e4b01ee61b244)

This is the asset file in the project  
[timezone.txt](https://community.thunkable.com/uploads/short-url/kfU3lYxr6zHlQMuexfaOaac5u2I.txt) (394 Bytes)

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:25pm UTC](https://community.thunkable.com/t/how-to-get-users-timezone/1224457/15 "2024-11-08T13:25:15Z")

</div>


