Time Zone issues

Having just spent the last few hours dealing with the pains of trying to get all my datetimes consistent. I found this particularly helpful:

Many of the time zone functions (such as pyzt and timezone) do not seem to be very available for a free Anvil account, which made it difficult for me to print EST to the UI when UTC or naive was stored in the data tables. My recommendation for others is to make everything time zone aware by only pulling datetimes from the client (for example: do not run datetime.now(anvil.tz.tzlocal()) on the server and especially do not run datetime.now()). Then, when you want to store the datetime in a data table, transfer this to the server and add it. It is automatically stamped with the local time zone info. This seems to be the only way everything works consistently for me without a huge headache.

1 Like