Forum Documentation Showcase Pricing Learn more

[SOLVED] Looking for way to get user’s timezone


#1

I’d like to store the user’s timezone on signup. However, when I store the current_date/time:formatted as “Z”, the timezone is always stored as “UTC” in the database. How do I get the timezone from the User instead of the Server?

returns “UTC”


image


#2

Why do you need to store this?

I’m asking because I thought I needed the same in order to display dates corrected for timezones. Turned out I didnt and I managed through another way.

I may have some code still somewhere that will give the browsers offset which is basically the same thing. If I remember correctly there are two plugins you could use. TimezoneDB and Unix converter. They should also do the trick


#3

Valid question. I need it for another API call that goes out through the API workflows. I need the ISO America/New_York format timezone for each user.


#4

Well, I guess the simplest way is to go via location and return time zone ID

image

This is the “America/New_York” format.

However that will either mean using browser location or asking them to enter a location via a search box (which is what I am doign above).


#5

Thanks Nigel. This definitely works. And, yep, I saw the prompt.

I ended up adding a little JS using toolkit which achieves the same thing without a prompt.
bubble_fn_timezone(Intl.DateTimeFormat().resolvedOptions().timeZone)


#6

Maybe just to complement, this is how I got the UTC offset:

> <script src="https://cdn.jsdelivr.net/npm/moment@2.19.0/moment.min.js"></script>

then the javascript to bubble element:

var offsetIs; offsetIs = moment().utcOffset();
bubble_fn_offset(offsetIs);


#7

Thanks for this as well. We also need to the time offset. I’m told that the latest version of Bubble apparently will expose the offset as a new feature. We’re behind the main cluster, so haven’t tried it out. Nice to have options if needed.


#8

Hi All,

I’m trying to get the timezone format 00:00. I can use a stored address in the appointment, but how can I reformat correctly? How can I convert from “America/New_York” to +/-00:00?

P.S. I’m using this for the Google Calendar plugin’s create an event - start time and end time, if it matters.

Thanks!


#9

Bubble was working on a feature expose the offset. Not sure if they completed it. This would be the way to go.

We solved this two ways:

  1. I loaded a reference table. This doesn’t handle daylight saving so it’s not a real solution.
  2. I also have JS on the page (am using toolbox) to get the users browser timezone and offset.
    https://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp

Are you trying to convert New_York time to UTC? Why 00?


#10

Hi, thanks for your response! I’m trying to use the Google Calendar plugin to create an event. I have everything right but at the end of the “start time” and “end time”, I’m supposed to include +/-2digits:2digits to represent the time zone. But I can’t figure out how to make this a calculation based on the user. I was hoping maybe I could take the timezone ID and convert it further, do you think that could work?

Thanks again!


#11

If this is the plugin you’re using, I’d start a new thread with this question. There are 1000 apps that are using it; someone has a solution. I needed the user’s timezone offset for a different API, or I’d have screenshotted you the solution.


#12

Thanks