Time Zone
Our restaurants are located in multiple time zones. This means Time.now and Date.today are not always valid for restaurant-specific logic, because they return the server’s local time rather than the restaurant’s local time.
Use the restaurant’s time zone to get the correct local time. The restaurant object is available from the current request context (e.g., current_restaurant in controllers or passed as a parameter in services).
Time.use_zone(restaurant.time_zone) do
# Returns the current date in the restaurant's time zone
Time.zone.today
# Returns the current time in the restaurant's time zone
Time.zone.now
# Returns tomorrow's date in the restaurant's time zone
Time.zone.today.tomorrow
# Returns yesterday's date in the restaurant's time zone
Time.zone.today.yesterday
end