gpt4 book ai didi

ruby-on-rails - Date.current 和 Date.today 之间有什么区别?

转载 作者:行者123 更新时间:2023-12-03 07:23:41 26 4
gpt4 key购买 nike

他们似乎都在做同样的事情。我只是担心一个人使用的时区与另一个人不同。

最佳答案

参见 Rails 代码,第 40 行 here .

# Returns Time.zone.today when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are     set, otherwise just returns Date.today.
def current
::Time.zone ? ::Time.zone.today : ::Date.today
end

因此,如果您定义了时区,您将获得分区日期,否则您将获得Date.today

顺便说一句,没有 Date.now

关于ruby-on-rails - Date.current 和 Date.today 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6635363/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com