Change Time zone in pure ruby (not rails)

前端 未结 5 1309
暖寄归人
暖寄归人 2021-02-14 07:02

I am building a Sinatra site which has mixed UTC/PST data sources, but will be viewed in PST. So I need a way to easily convert Time objects from UTC to PST. Without Rails, I d

5条回答
  •  独厮守ぢ
    2021-02-14 07:57

    In Pure Ruby

    Time.now.utc.localtime("+05:30")
    

    where +05:30 (IST) is the offset of the particular zone

提交回复
热议问题