When using the localtime
method on a UTC Time
object, is the time returned the local time as specified in the app configuration or the local time of the user's location?
Asked
Active
Viewed 740 times
1

Stefan
- 109,145
- 14
- 143
- 218

Prior Mabe
- 15
- 4
-
Possible duplicate of [Convert UTC to local time in Rails 3](https://stackoverflow.com/questions/5300493/convert-utc-to-local-time-in-rails-3) – jeffdill2 Feb 07 '18 at 16:14
-
Rails has custom classes and methods for dealing with timezones, e.g. [`TimeWithZone`](http://api.rubyonrails.org/v5.0/classes/ActiveSupport/TimeWithZone.html) and various [extensions](http://edgeguides.rubyonrails.org/active_support_core_extensions.html#extensions-to-time). Within a Rails app, you should use those methods instead of the built-in ones. – Stefan Feb 07 '18 at 16:38
2 Answers
2
localtime
will give you the time in the current time zone of the machine running the code.
Apidock(localtime): for ruby, ruby on rails

Michael Arkhipov
- 737
- 8
- 19
0
.localtime in your app will show your app's time. To display localtime to different users you will need to add some Javascript. This answer might help you.

Alex A
- 156
- 1
- 10