0
我想查看當前時間是否在中午(午餐)之後。如何計算Ruby中時區的時差
noon_time = Time.parse "12:00 pm"
current_time = Time.now
if current_time < noon_time
#eat a big meal or sleep its after lunch time
else
#work hard its not time to eat
end
當我在9:38 pm運行這段代碼時,它說「吃大餐」。
我是否需要做這樣的事情並捕獲用戶爲我的網站設置的時間?
offset = Time.now.in_time_zone(current_user.time_zone).gmt_offset/60/60