Rails 3: How to get today's date in specific timezone?

前端 未结 9 1180
清酒与你
清酒与你 2021-01-30 06:21

To get today\'s date I do:

Date.today    # => Fri, 20 May 2011

I would like to get today\'s date in a specific timezone, say \'Melbour

9条回答
  •  花落未央
    2021-01-30 06:55

    Date.current

    Date.current is probably the most clear and succinct way, and was added in Rails 3.

    $ Date.current
    #=> Sat, 14 Jul 2018
    

    http://apidock.com/rails/v3.2.13/Date/current/class

提交回复
热议问题