I saved some data with the server using datime.datetime.now()
. How do I display this for the user in another timezone?
This might help:
1 Like
Many thanks. Anvil continues to impress me with the things you have already thought of.
So can I conclude that a client will always show the non-DST time of their location, irrespective of how the datetime.now() was created? Can I recover the original timezone from the database entry?
For example,
What are my expectations of this code in various countries?
self.registered_greeting.text = """
Welcome back, %s!
You last logged in on %s, after first registering on %s.
Your login expires automatically on %s, unless you logout yourself.
""" % (name,
user["last_logged_in"].strftime("%d/%m/%Y at %H:%M:%S"),
user["date_registered"].strftime("%d/%m/%Y"),
user["token_expiry"].strftime("%d/%m/%Y at %H:%M:%S"),
)
Where all the dates were generated in the server.
Does it work storing on the server in UTC and converting on the client with the following?
user["last_logged_in"].astimezone(anvil.tz.tzlocal()).strftime('%d/%m/%Y at %H:%M:%S')
2 Likes
I see two consecutive dots.
1 Like
Works as described! Many thanks.