ruby get Time in given timezone

前端 未结 9 1234
情书的邮戳
情书的邮戳 2020-12-28 13:17

In ruby, how can I get current time in a given timezone? I know the offset from UTC, and want to get the current time in the timezone with that offset.

9条回答
  •  心在旅途
    2020-12-28 13:51

    An easier way to do it is to simply pass the offset (in integer form) to the ActiveSupport::TimeZone hash:

    ActiveSupport::TimeZone[-8]
    => #, @utc_offset=nil, @current_period=#,#>,#,#>>>
    

提交回复
热议问题