Is Time.zone.now.to_date equivalent to Date.today?

前端 未结 4 1464
栀梦
栀梦 2020-12-28 12:47

Is Time.zone.now.to_date equivalent to Date.today?

Another way to put it: will Time.zone.now.to_date == Date.today always be <

4条回答
  •  旧巷少年郎
    2020-12-28 13:27

    # system timezone
    Time.now.to_date == Date.today
    
    # application timezone
    Time.zone.now.to_date == Time.current.to_date == Time.zone.today == Date.current
    

    http://edgeapi.rubyonrails.org/classes/Time.html#method-c-current http://edgeapi.rubyonrails.org/classes/Date.html#method-c-current

提交回复
热议问题