Time zone adapt for differnt users connection to app

Hello, hope all is fine!
I need help to figure out this problem:

My datatable have column ‘TIME’ return me data like this example:
17/08/2022 18:54:59
There is any think to convert the time to adapt it to differnt timezone of different users?
for exaple:
user_1 see the app from France
user_2 see the app from Usa

Thank you!

Have you read through the docs on timezones? Anvil Docs | Dealing with timezones Or possibly this forum post where an Anvil staff member explains how time zones are handled? Time Zone issues - #3

Anvil should, automatically, do conversion to and from the user’s time zone. If that isn’t working for you, you’ll need to give a lot more detail about your use case and why it isn’t working.

Hello, thanks for repley,
Yes i read the documentation and i put this on my server code:
datetime.now(anvil.tz.tzlocal()

then i do several try, im trying with my local hour (server_1) is match then on another server(server_2) with another local time is not make any conversion but return the hour of initial server (server_1)
Any idea how to fix it ?

Not until you show a lot more context. Remember, we can’t see everything you’re seeing. We can only see those parts that you show us. Right now, we just don’t have enough of the picture.

If you want Anvil to do the time zone conversions for you, generate your datetime on the client, and pass it to the server.

How i can take the column of time and convertit with anvil.tzlocal() ?
my datagrid are gied from:
self.repeating_panel_1.items = app_tables.my_table.search(tables.order_by(“TIME”,ascending=False))

Here’s a custom component that will display datetimes in the user’s local time zone in data grids: Local Timezone Display in Data Grids

You can either use the component directly, or look at its code for how it works.

1 Like

Hello, thanks for replay im reading the component and is make conversion on label_1 how we can do the same things for a datagrid like this:

Go through the tutorial on data grids. The last part of it shows putting components onto a data grid row to make it editable. You can put any component on, not just edit fields. You could put a label on, for example, and then set its text property.

1 Like