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?
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?
Ruby's Time
class knows nothing about any "client". You would have to inspect request headers for that. Time#getutc
and Time#getlocal
seem to be what you want. Notice the variant on getlocal
where 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.