In Rails, what's the nicest way to create a specific time (not now) in a particular time zone?

后端 未结 5 720
庸人自扰
庸人自扰 2021-02-01 01:36

Here\'s one way, but it\'s can you think of a nicer or more \'railsy\' method?

>> Time.use_zone(\'Sydney\'){ Time.zone.parse(\'2011-04-12 2pm\') }
=> T         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-01 02:07

    How about using the *in_time_zone* helper..

    Time.now.in_time_zone('Sydney')
    

提交回复
热议问题