Action based on user timezone

I want to have a workflow, which resets a field, to run every night at midnight based on the user’s timezone… Do I need to have the user pick/set their own timezone…? Do I need any special timezone plugin to do this? How do people handle scheduling things based on the current user’s timezone? Never had a need for this before. Thanks.

You can set the user’s timezone in your database without the user inputting anything. If I recall correctly, simply run an action and save the user’s current time, custom format = Z, in the user’s time. (Z in the custom format displays the user’s time zone).

Then you can schedule things based on the user’s timezone. There are a few APIs mentioned in the forum for this. I know @kramwe set one up at one point. So, you’d simply pass the data to the API to determine what time in UTC to have the action scheduled for so that it goes out at a particular time for that user.

On the surface all of this is straightforward, but for some reason it seems to get complicated in practice. Just a heads up.

Hi - I’ve actually done a lot with times and timezones and scheduling in Bubble. Here’s my suggestion… seems like a lot but it’s fairly easy to setup.

First, I store the user’s timezone using the following logic

  1. install toolkit plugin

  2. you can get the user’s timezone with JS.
    In workflow, add “run javascript” plugin action
    paste in this:
    bubble_fn_tz(Intl.DateTimeFormat().resolvedOptions().timeZone)

  3. On page, add “javascript to bubble” element
    image
    set it up like this:

  4. Then you can store the user’s timezone in your database.

Then, if you’re looking to say send an email digest every morning at 7am (based on the user’s timezone), you could use Bubble’s recurring event API workflow, or use a program like EasyCron to create the schedule. I like EasyCron. It’s easy.

You could have 1 Easycron job per timezone (if you have a limited set). Or you could have one Easycron per day, hit Bubble, to then cause Bubble to setup separate schedules for each user based on their timezone offset (you can load this as a reference table).

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