I want to know if Time.localtime returns the user local time or the server local time.
If it is the server, is it any clean way to convert a UTC time or datetime to user local time?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ruby’s
Timeclass knows nothing about any “client”. You would have to inspect request headers for that.Time#getutcandTime#getlocalseem to be what you want. Notice the variant ongetlocalwhere you can enter the TZ offset – if you pass it the client’s TZ, you can get the client’s local time. As I said earlier, you would have to look into the request headers to figure out which TZ it is.EDIT: Scratch that, apparently there does not have to be a Date header in a request. So you’re down to JavaScript to tell you about the time zone.