ruby get Time in given timezone

前端 未结 9 1232
情书的邮戳
情书的邮戳 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:36

    now = Time.now
    now.in_time_zone('Eastern Time (US & Canada)') 
    or 
    now.in_time_zone('Asia/Manila') 
    

提交回复
热议问题