Skip to content
How-to guides and worked examplesSee the guides →

Time API ​

Per-option reference for the :time field. For tasks and examples, see the Time guide.

Options are passed to a field declaration in an Avo resource, such as app/avo/resources/event.rb:

ruby
field :starting_at, as: :time

Shared options, including link_to_record, are covered in common field options.

Display formatting ​

format

The format used on Index and Show pages. Locale-sensitive tokens use the page's locale.

ruby
field :starting_at, as: :time, format: "HH:mm"

picker_format

The visible input format on New and Edit pages. It does not change the submitted time format.

ruby
field :starting_at, as: :time, picker_format: "H:i"

Different token systems

format uses Luxon tokens; picker_format uses flatpickr tokens. They are not interchangeable.

Timezone conversion ​

relative

Controls whether the time is converted from UTC to the display timezone. This is timezone conversion, not relative wording such as "two hours ago".

ruby
field :starting_at, as: :time, relative: false
ValueBehavior
trueDisplays and edits in the configured timezone, or the browser's timezone when none is configured; picker changes are converted back to UTC.
falseDisplays the UTC clock time on Index and Show; the picker retains that clock time and submits it without applying a timezone offset.
  • Type: Boolean
  • Default: true

Date used for conversion

For time-only values, Avo reparses the UTC clock time using today's date before converting it for display or editing. Offsets therefore follow today's daylight saving rules, not the date attached to the stored value.

timezone

The display timezone when relative is true. A block can return a different timezone for each record.

ruby
field :starting_at, as: :time, timezone: -> { record.timezone }
  • Type: String or Proc / Lambda returning a timezone identifier or nil
  • Default: nil (uses the browser's timezone)
  • Values: Timezone identifiers understood by Luxon, such as "America/Los_Angeles" or "UTC". See also Rails' timezone documentation.
  • Context: Blocks run in Avo::ExecutionContext with record, resource, and view available.

INFO

With relative: false, the configured timezone does not shift the displayed clock time. Avo normalizes "UTC" to "Etc/UTC" on form views for compatibility with Luxon.

Picker controls ​

time_24hr

Controls the picker's hour selection. Index and Show formatting is controlled separately by format.

ruby
field :starting_at, as: :time, time_24hr: true
ValueBehavior
falseUses AM/PM selection.
trueUses 24-hour selection.
  • Type: Boolean
  • Default: false

disable_mobile

Disables flatpickr's native mobile picker fallback. See flatpickr mobile support.

ruby
field :starting_at, as: :time, disable_mobile: true
ValueBehavior
falseAllows a native mobile picker where flatpickr supports it.
trueUses flatpickr on mobile too.
  • Type: Boolean
  • Default: false

picker_options

Additional flatpickr options, applied on New and Edit pages. Avo fills locale.weekdays and locale.months from the app locale and merges a supplied locale over them. The Time field has no calendar.

ruby
field :starting_at, as: :time, picker_options: { minTime: "09:00" }
  • Type: Hash
  • Default: {}
  • Values: flatpickr options.
  • Validation: These settings constrain the picker, not server-side model validation.

Avo-controlled settings

Avo sets altFormat, disableMobile, locale.firstDayOfWeek, enableTime, enableSeconds, noCalendar, and dateFormat after merging picker_options. Avo also supplies defaultDate when the field has a value. Those settings cannot be overridden through this Hash. Other options, including time_24hr and callbacks, are forwarded to flatpickr and can replace Avo's defaults.