Reputation: 8060
My app in django requires to tell the user what time an action occurred. Aside from asking the user what timezone he/she is in, is it possible for me to generate the time on the client end?
Off the top of my head, are there a particular representation of time that is timezone independent, (unix time?), and then I can simply paste it into the html and have the client end (browser) findout the timezone and then do the calculation?
Upvotes: 2
Views: 287
Reputation: 10146
Haven't used it myself, but I think this is what you are looking for.
Upvotes: 2
Reputation: 12195
I'd make all my times UTC, as that's a good international-level reference point, and you can always shift that to a local time, given that you know the user's TZ.
I'd also use the time on the server (datetime.datetime.now()
) rather than rely on the client's system clock, as this makes it easy to fake what time something happened at.
Upvotes: 2