Timezones are annoying. Luckily Explo makes it easy to manage timezones for your dashboard on a granular level to enable you to serve data to your customers in the most accurate form possible.
Out of the box, Explo dashboards behave in a predictable fashion with regards to
timezones. Explo assumes that all of the data coming from your database is in
UTC format
(as it should be).
We then convert the dates to the local time of the user that is viewing the
dashboard to show them the data.For example, if a user views the dashboard from PST, then Explo shows all of the
dates converted from UTC to PST. If a user views the same dashboard from EST,
Explo displays the dates convert from UTC to EST.
If you go to a dashboard’s settings dropdown, you will see a section called
“Timezone”. Here you can choose between two options: “User Local Time” and
“UTC”.The default for all new dashboards is UTC, which behaves the way
described above. In most cases, the default setting should be the best approach
and give your customers the most consistent viewing experience.However, there are times when you will want to have more granular control or
force the customer to view the dashboard in a certain timezone. In those cases
you’ll want to use the UTC setting.
UTC dashboards will display all datetime data exactly as it was received from
the query. We won’t do any conversions to the user’s local time. If your DB has
a datetime stored at 11 PM UTC, the data on the frontend will interpret and
display it as 11 PM.
Since the dashboard will show the users the dates exactly as they are coming
from the backend, you can use this setting to set the dashboard to either a
specific timezone, or a user-configurable timezone.
To do this, you should convert the datetime data in your SQL queries to the
timezone using your database’s SQL dialect. For example, in postgres, you can
convert your data to PST timezone as follows:
Copy
Ask AI
select created_at at time zone 'utc' at time zone 'pst'from users;
When the data is then retrieved from the backend, Explo will show it as is, in
PST.
It is also possible to create dropdown on the dashboard which your users can
then use to set the timezones to their preference. To do this, create a
Dropdown Select element
and make the options the various timezones that you want your users to be able
to use. Default the dropdown to the default timezone you want the dashboard
rendered inThen, in your queries, you can modify the hardcoded timezone to be configurable
as such:
Copy
Ask AI
select [[created_at at time zone 'utc' at time zone {{timezone_dropdown}}]]from users;
Now, when your users switch between timezone options in the dropdown, they can
change the timezone of the data in the UI.