Date and Time data structuring

Time is only a construct :exploding_head:
Because its 5 o’clock somewhere :tropical_drink:

In all seriousness. It is a nag for developers everywhere–not just bubble. I don’t think this is a technical issue as much as it is a conceptual one that requires a certain way of thinking about time that I don’t think is very intuitive for non-programmers / most humans.

Timezones are confusing even if you aren’t programming
I can’t tell you how many conference calls have been incorrectly scheduled because both parties thought they were scheduling to meet in their own timezone. We are inherently self-centered I guess :slight_smile:

Bookings are way different than just keeping track of time for an individual user.

You have to stop and think about what you want to do here because no software will truly know your intention and be able to do this for you, however bubble has done a lot to help with this. @keith has explained much of this.

I actually don’t think this is as complex as it seems–especially in your scenario. You already mentioned you don’t require multiple timezones. You’ve eliminated most of the confusion.

A bubble webpage gets the time zone from the device

If all users are in physically reside in same timezone and their clocks are set the same, then you are all reading and writing dates in the same timezone. I don’t think you’ll have a problem.

You’ll want to be careful though for edge cases though such as if you have users who are traveling on holiday to a different timezone and are logging into the site to book a date/time because they will be doing so in the local timezone where they reside.

Times will be shown in their local time by default. Time will also be entered from datepickers in local time, which means they’ll have to do the math in their head to enter the time correctly. i.e. if they want to book 3PM in London, but are physically in New York, they’ll need to enter 11:00AM to book the correct time. (Difficult)

You can force bubble to display times in a certain timezone no matter where the user is located.

I’d take a look at the full documentation for this.

Date pickers will set times in the local timezone. You can use an offset number between the local timezone and the timezone of truth and then take the output of the datepicker and adjust it back to the correct timezone.

How do you get the offset number?
The number will be different depending on where you are in the world and needs to be calculated by subtracting device’s local timezone from the timezone of truth. You should be able to calculate this offset number in bubble, but I’ve found that its hard to force the result in the expression.

I created a simple plugin called date and timezone tools to help with that and return the offset number for you. (There are others)

So then you take that offset number and do this as you save your time. If your offset number is calculated to be -4 such as NYC to London then as follows

  1. A user enter 3:00PM in the picker
  2. The picker outputs a time of 3:00PM NYC / (7:00PM London)
  3. You put an expression to adjust the time before saving to the db
    Booking Picker’s date:+hours:-4 (subtracting 4 hours)
  4. The new adjusted date is saved into the database as 11:00AM NYC / 3:00PM London

I’d make sure to let the user know this is what’s happening with a label near the picker ‘time in GMT’

Regarding dates as texts

Did you look at the editor link I sent?
Do a search for Event’s date returns a list of dates
Do a search for Event’s date:converted to ‘mm/dd/yyyy’ returns a list of texts

There are a few ways to skin this cat as far as implementation. What I did was one way.

3 Likes