Above image shows the PST time according to the server which app is being hosted.So my requirement is how to show the time of the user who logs into the site according to his Time Zone ?
Asked
Active
Viewed 104 times
0
-
(Note that it's not clear whether you really need a time *zone*, or just the UTC offset for a specific point in time. You probably want to just pass the UTC point in time to the Javascript, and do the rendering on the client side which will be able to know the UTC offset for that point in time.) – Jon Skeet May 20 '14 at 12:55
-
@JonSkeet As shown above it's a PST time(USA & Canada).So I need to show the time according to the client's time zone and then save that time on DB ? How can I do that ? – Sampath May 20 '14 at 13:03
-
1Why would you want to store a time zone in the database? Do you *really* need to do that? As for displaying the right time - as I said, just send a UTC point in time to the client, and render it in Javascript, which knows the local time zone. – Jon Skeet May 20 '14 at 13:06
-
@JonSkeet I don't need to store the time zone in the DB.Need to save the user's log-in time according to his time zone. – Sampath May 20 '14 at 13:08
-
*Why* do you need to save that? What are you going to do with it later? If you really need to, you can determine it in Javascript as show in the duplicate question. – Jon Skeet May 20 '14 at 13:17
-
@JonSkeet This is an app which logs the employees login and logout times.That's why it requires to save that time.Is there any problem about that,if I save the UI shown time ? – Sampath May 20 '14 at 13:24
-
Why not just log the UTC time? Aside from anything else, that means it's *trivial* to find out how long a user has been logged in for - you don't need to take daylight saving time into account, for example. At any time, you can later display that in the user's time zone - or in any other time zone. Another benefit is that then you're not trusting the user's browser for anything... what would the impact be under your scheme if they'd manually changed their time zone? – Jon Skeet May 20 '14 at 13:26
-
@JonSkeet Yep.I got your point.Thanks a lot.If you put your comments as an answer,I can accept it.Thanks again. :) – Sampath May 20 '14 at 13:40
-
No can do, as I've already closed the question as a duplicate. There are probably duplicates of "how should I store date/time values" too... probably best to just delete this question to be honest. – Jon Skeet May 20 '14 at 13:47