UTC time vs current user time

Hello all,

i am faced with a problem, i am trying to build an in app messaging system. the problem is the date/time is captured from current user machine and i don’t have a way to know in which timezone the user is.

So if someone where to place a message in GMT+4 and someone to to reply in GMT+1 where the difference is 3 hours but how can i determine this.

Any help will be appreciated. thanks

The date that is actually stored in the database is unlikely to be the localized date (although it may appear to be so in the app data viewer). So you shouldn’t have issues when listing objects by date created.

Thanks for the reply Scott. Anyway to determine which timezone the user is in and which timezone the database is in. This way I have a method to display the created thing in the users local time

You might need to get UTC from a Blockspring call and use that on your timezone sensitive field.

Thats going to be a lot of blockspring calls for messaging between users.

Does anyone have another idea?

Just to make sure you’re not working on a problem that you won’t run into, could you provide further details on what your use case is and what issue is actually occurring? In particular, why is it important to know the timezone?

I just don’t want you to put effort into a problem that you won’t occur in practice. As far as I know, the time is displayed in the user’s local time, but I haven’t tested this hypothesis. If you have a link to the app, I can write a few messages there saying what my local time is so you can see if the time is displayed correctly in your local time (I’m PST).

Please let me know if I’m not understanding your case correctly.

1 Like

The issue, I think, is one of “countdowns / deadlines”.

So if I set a deadline for something in MY time + 4 hours …

And then you want to know when it expires in YOUR time zone… you don’t know unless you know the timezones.

@NigelG I was hoping that wasn’t the case and the local time is determine dynamically. That indeed makes it cumbersome. I don’t have a solution for it at the moment. :confused:

I know :frowning:

Could you chunk it up into 5 minute blocks… And instead of storing times store “minutes left”. Then a background process updates the minutes left - 5 every 5 minutes ?

Do any of the APIs return UTC other than Blockspring ?

So if I set a deadline for something in MY time + 4 hours …

And then you want to know when it expires in YOUR time zone… you don’t know unless you know the timezones.

strange, if it keeps the date in timezone agnostic format on the server it should work

what I mean is that Bubble knows its own timezone and current time on the server and can ask the client what is the local time and calculate the time difference from its own server, then from it calculate the client’s timezone

that is if Javascript can’t give such info itself

That is exactly the solution that is needed. This would work. Another alternative is to some how arrive at users timezone using the connected IP address.

using geolocation wouldn’t work I fear with people behind VPNs working from another country

I will be willing to live with that. After all they should know are using a VPN