Convert timezone

Hi, is there a way to convert the timezone ID like “America/Denver” that I got from the plugin Browse timezone and locale into someting like “Mountain Standard Time” and as well as the other timezone ID based on current user. I was hoping to store PST, MST, EST and CST to a database rather than the timezone ID that was given.

Thanks every one.

What’s the reason for wanting to do this?

Time zone IDs are better than named offsets (abbreviations) in almost every way. What’s the use case here?

I wanted to show the count of how many orders are there on a specific timezone which are Pacific, Eastern, Mountain and Central Standard Time rather than to show the ID which will be a lot I’m guessing. So I want to minimize it with those 4.

Is this possible?

You need to save the offset at the time of record creation on that record itself

Times are stored as milliseconds on bubbles database and are coerced into local time locally on your device unless converting a date to a string on the backend.

@jared.gibb True. I’m already on that part. What I mean is I want the data or timezone that was stored on the database (America/Denver or America/New_york) be converted as Pacific, Eastern, Mountain and Central Standard Time or be displayed as such.

I was thinking on creating a database of timezone to convert them by using a condition, or is there a better way?

So like. If it was purchased 9am on the west coast but you are viewing the data anywhere else in the world, the time you see display on screen should say 9am?

Yes and also show its timezone. (Pacific, eastern and etc)

you need to save timezone names, not their region

America/Los_Angeles, America/Detroit (for example)

then you can do stuff like. this
Screen Shot 2023-08-31 at 9.04.30 AM

and get results like this (i am in America/Detroit for reference)
Screen Shot 2023-08-31 at 9.05.30 AM

so here we are looking at a point in time. we can see what that point looks like in it’s native timezone (America/Detroit_) or we can see how it would appear on the west coast (America/Los_angeles)

it works the other way around too. if a record was saved with a timestamp that represented 9AM in los angeles, if i didnt coerce the timezone as shown in the image above, the time would display 12PM when i look at it here. If i did use the timezone coercion as shown above, it wouuld display 9AM which can be confusing if you dont include the timezone name in the display

Thank you for your clarification. Exactly what I was looking for on another feature of the app that I’m building. I did what you have shown and it worked well.

This topic was automatically closed after 70 days. New replies are no longer allowed.