Time Zone Related Question & Bubble

Is it possible to create a new Thing that has a time (example, a departure time) but have that set to a specific time zone, or inputted/converted to UTC time, and when Bubble displays that time, it automatically relates the UTC time to the browsers current time zone, or in the event that the time zone is different, displays +a day or +6 hours?

A time doesn’t have a timezone, it’s something absolute. What has a timezone is a display of the time.

1 Like

@JustinC Hi there, I have a similar situation for a travel App I’m building. I have tried to capture the issue in the bubble open app, available here.

Take a look and let me know if it accurately demonstrates your use case. Feel free to make corrections.

@emmanuel Is there a way to make this work in Bubble? For example, consider this use case in my travel App.

Let’s say I’m using the App today in New York. I enter the details of a flight I will be taking from Tokyo to Seoul in 2017. I enter the departure date / time (Tuesday, 10 January 2017 - 22:00 / 10:00 PM) and also the airport i.e., Tokyo Airport.

Since I’m in New York when I enter the details, Bubble stores the departure date and time in UTC but corrected for my local time i.e. New York. Bubble is going to store the UTC as of Wednesday, 11 January 2017 04:00, i.e. 1484107200000. New York is GMT - 5 on 10 January 2017. So the user local time correction to the date / time entered is + 5 hours

I’m in Tokyo in 2017. When I view the same flight in my App then, the date and time of the flight are going to be totally wrong!

Instead of storing the UTC as of Tuesday, 10 January, 2017 - 13:00, Bubble is instead storing the UTC as of Wednesday, 11 January 2017- 04:00.

Is there a way - for such use cases - to bind the date/time with a geographic location so that we have and store a universal time reference.

Alternatively, if I can get the RAW UNIX timestamp for a date/time (without correction for user local time), that can work too. I can use this RAW UNIX timestamp with Google Time Zone API to store and display the correct time.

1 Like

A date object doesn’t have a correction for local time, the correction for local time is a display thing. The timestamp is an absolute concept.

And you can access the Unix timestamp of a given date, https://bubble.io/reference#Data.Messages.date.extract_from_date

But a time chosen on a laptop in the UX will be in the local timezone, we don’t support changing the timezone for input (though i guess you could build this yourself with a dropdown and doing the math yourself, a bit of a pain but doable).

I understand that the time stamp is an absolute concept and UTC is a time standard that is the basis for civil time and time zones worldwide. This means that no country or territory officially uses UTC as a local time.

In my updated example here, I’m taking a date as an input and displaying the UNIX time stamp. I’m also storing the same date in the database, then getting its UNIX timestamp.

Maybe I’m not understanding you correctly.

The UNIX timestamp does seem to depend on user local user time. I tested this by changing the local time on my desktop to New York time zone. For the same date and time i.e., 24 October 2016 17:00:00 (5 PM), the UTC timestamp returned is 1477342800000 which translates to 24 October 2016 21:00:00 (9:00 PM) (UTC). The UTC seems to be calculated based on (1) date + time entered and (2) user local time.

For the use case above, it would great to have a new date data type “UTC Raw” which stores the date as entered in UTC format without any correction for user local time.

The UNIX timestamp is the number seconds since Jan 01 1970. (UTC). http://www.unixtimestamp.com/.

So you can use this as an absolute date

I think we are talking past each other :slight_smile:

On the http://www.unixtimestamp.com/ website, I entered 24 October 2016 17:00:00 (5 PM), the output for UTC is:

It does not match the UTC value stored in Bubble for the same date+time:

It looks the standard JavaScript UTC functions have a problem - they always correct for user local time - as highlighted in this stack overflow thread. This is okay for most use cases.

A more practical implication is explained here.

One “neat” (awful) feature in JavaScript is that it automatically changes dates to be in whatever timezone the user’s computer is set to.
This is great if you are building the online version of The Podunk Gazette and all your servers and users are in one town. Otherwise, it can introduce small inconsistencies between clients and your backend servers.

I’m looking for a way to the get the UTC for a given data+time (ignoring user local time) - essentially - what is the UTC for the date+time entered when the user local time is GMT.

It is highly possible that I am not understanding UTC as a concept :smile:. It also possible (but complicated) for me calculate on the fly the correct UTC for my needs.

I want to avoid this and was hoping a solution exists as a standard bubble feature. This feature becomes important for scheduling / travel application where dates are usually bound to locations different from the user local time.

My bad. Then Bubble doesn’t support that currently.

I’m having an issue with UTC as well. Specifically storing the value. The scheduling tool that we use outputs the time as UTC (as most apps do) and it’s making something as simple as sending off an email in a user’s timezone a nightmare. @madras did you ever figure this one out?

1 Like

@david Yes, for my use case.

Though I had to do a lot of mental gymnastics (and use an external API) to get it work.

1 Like

@madras, any chance you could show us how you solved this by creating an example in the forum?

I’m trying to collect time inputs from users in (potentially) different time zones than their current time zone which sounds like the exact same problem you solved. It’d be incredibly helpful if you could find a way to post your answer.

While a working copy in the forum would be awesome, even screenshots of your implementation would make a big difference.


It is a bit complicated.

One option - assuming there is a need for this - I can make my solution into a plugin and release it as such.

Let me see what I can do but no guarantees :slight_smile:

Hi @madras, we just finished building our approach. We used some open source code in R and hosted it on blockspring which makes it really easy to call from Bubble.

Also, I believe someone else just recently created a Bubble plugin for time zones (we saw it after we created our own) so it may not make sense for you to build one since it may already exist. Just FYI.

Thanks for the offer! Really appreciate the help/support. It’s a tangible example of what makes the Bubble community so great!

Old thread but still seems like a problem, so I published a new plugin that’s super easy to use called ConvertTime.