date_with_local_time
Given a time object, format it in the given timezone, translating to the user's local time if it isn't the same.
Parameters
format
(String
)
A time formatting string, like the one the built-in Liquid "date" filter uses (see http://strftime.net for examples). We recommend including "%Z" in this string in order to have an explicit time zone specifier.
input
(ActiveSupport::TimeWithZone
)
A time object
timezone_name
(String
)
An IANA timezone name to use for the default format. If not given, this filter will try to use the convention's local timezone (if one exists).
Returns (String
)
Examples
Formatting a time using an explicit time zone, while the user is in that zone
{{ convention.starts_at | date_with_local_time: "%l:%M%P %Z", "America/New_York" }} =>
"7:00pm EDT"
Formatting a time using an explicit time zone, while the user is not in that zone
{{ convention.starts_at | date_with_local_time: "%l:%M%P %Z", "America/New_York" }} =>
"7:00pm EDT (4:00pm PDT)"
Using the convention's time zone implicitly
{{ convention.starts_at | date_with_local_time: "%l:%M%P %Z" }} => "7:00pm EDT"