Timestamps Server vs Client

This is because you used time.mktime(), which interprets its input as a local time (and then adjusts to produce an output in “seconds since the epoch”, which is defined as midnight UTC on Jan 1st 1970).

Generally speaking, the time.* functions in Python are full of timezone-related bear traps. You should avoid them and use datetime everywhere.

(Fun fact: Anvil handles datetimes intelligently! If you pass a time-zone-unaware datetime to or from a server function, it gets stamped with the timezone of wherever it came from. So when you collect a datetime in a DatePicker on the client, pass it to the server and store it in a data table, it (correctly) ends up in the client’s time zone.)

1 Like