Open Block for Converting Timezones

FYI - Made a simple little Timezone converter with Blockspring. It’s open, so if you want to use it, just add through the Bubble-Blockspring plugin.

https://open.blockspring.com/whitney-kramer/2d047f3d793c5e8dfde8b12ad97e117b

3 Likes

Awesome, works well!

Responding to questions:

Here’s a deeper look into how to structure the POST.

Use UTC as the From Timezone.

Format the DateTime as: yyyy-mm-dd"T"HH:MM:ss"Z"

Bring the data back into Bubble as type = date

Awesome tool, a real life saver.

I guess there won’t be a version of this not through Blockspring? Will definitely pay for this, as Blockspring now costs 15 a month…

We looked ~ a year ago for a free API that could do the same and didn’t find one. Let us know if you find something.

BTW - You can copy the code and own your own version if you want to as well.

Copying code would still require blockspring to make it work right?

The @romanmg timezonedb plugin looked promising but it seems ot cannot return an actual date. But maybe in wrong.

Correct. Blockspring is needed to host the code.

Awesome, @kramwe!

Hey @vincent56, I just made a quick change to the Convert call for the dates in the TimezoneDB plugin. Let me know if that helps!

What did you change?

@vincent56 I changed the to and from timestamps to be read as dates, but I’m actually testing this right now and running into a UNIX conversion issue. I’ll sort it out, but in the meantime, @jarrad’s UNIX converter has a few additional date/time/zone features. Have you seen it if fits your needs?

1 Like

Awesome, thanks for sharing! I tried previewing it in Blockspring, but the results tok 5-6 seconds to process, which unfortunately will not be quick enough in my case.

Before I work on implementing it, does anyone know if this will work any faster in the actual app, or is that the time I should expect it to take?

forget about this

Thanks. Indeed it is still saying it is a number and not a date:

However, I’m still not sure how to implement @kramwe’s block or your plugin because you always need a ‘to timezone’ which I’ve only seen figured out by getting the timezone ID from current user’s geo position or extract it from a timestamp. Using the UNIX converter plugin, each date i extract

the timezone from shows UTC which I guess makes sense because that is how it is stored. So far the UNIX conversion takes pretty long time to process and I’m implementing this on a RG with a lot of dates so this is not practical.

When I have the timezone it was submitted in, I can store it together with the date from the date picker but I can never have the date picker show that date because it requires formatting, changing it into a text instead of a date. I can mess around with a text field to show the date that shows the date picker (even the Air date picker) on click, but it is very messy and laggy :frowning:

It is clear I’m missing something here, but I need some help to figure out what :stuck_out_tongue:

@romanmg if you could have a look at the unix conversion for the timezonedb plugin, I think we have a winner!

There is indeed a problem with the way timezonedb plugin reads the unix timestamp:

This is my RG at the moment:

1: time picker with initial value: this RG’s date (it shows in timezone ET)
2. the timezonedb result:
image
image

where the time parameter is (4):

image

3 is the formatted date with the timezone that the RG’s date was stored in. WHich should be the output if the timezonedb plugin.

Is there any way I can help you in any way to fix this (if the problem is at all in your plugin!)? I’m overdue with an update and this is the final piece missing :stuck_out_tongue:

Hey Vincent,

I changed the fromTimestamp and toTimestamp to be read as numbers instead. Since Bubble can’t convert Unix to Date/Time format, I think another converter is necessary. Not sure if this is something that @jarrad’s UNIX converter plugin can do, but the Timezonedb docs don’t seem to have it as a part of their API (though they have the tool on their site grr…:confused:)

But I think at least having it read as number will allow for potential math do be done to it if necessary.

hey guys,the result doesnt look right for a complete fail…
what happens if there is a T in the middle of these two? and whats the go with the format? looks strange to me but im not full bottle in this area…
image

Thats a pity and indeed, the site shows a converter.

This will require another step in the conversion process then, another UNIX converter step. But if the date picker could only handle formatted dates (like you normally format a date and set a dynamic timezone), all of this wouldn’t even be necessary!

@vincent56 I have an update that may hopefully help?

  1. I added a new call to the Timezonedb plugin that lets you look up local time by zone name. The response includes a formatted date value. So instead of converting, you could enter in the zone itself - I’m not sure if this is useful to you, but the point is it includes a formatted date/time value.

  2. The Convert call also includes an “offset” value that may still be useful. The value of this is the difference of time in minutes between the two zones.

Thanks. I’ll have a closer look later tonight. I just want the date picker to display the stored time and date in the timeline stored so the out put needs to be a date.