Skip to content
On this page
On this page
This component requires JavaScript to function. Please refer to the Installation section to set it up.

Use LocalTime to format a date and time in the user's preferred locale format. This component requires JavaScript.

Arguments

NameTypeDefaultDescription
datetimeDateTimeN/AThe date to parse
initial_textStringnilText to render before component is initialized
weekdaySymbol:shortOne of :long and :short.
yearSymbol:numericOne of :2-digit and :numeric.
monthSymbol:shortOne of :long and :short.
daySymbol:numericOne of :2-digit and :numeric.
hourSymbol:numericOne of :2-digit and :numeric.
minuteSymbol:numericOne of :2-digit and :numeric.
secondSymbol:numericOne of :2-digit and :numeric.
time_zone_nameSymbol:shortOne of :long and :short.
system_argumentsHashN/ASystem arguments

Examples

Default

June 1, 2014 13:05 +00:00
<%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) %>

All the options

June 1, 2014 13:05 +00:00
<%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"), weekday: :long, year: :"2-digit", month: :long, day: :"2-digit", hour: :"2-digit", minute: :"2-digit", second: :"2-digit", time_zone_name: :long)) %>

With initial content

June 1, 2014 13:05 +00:00
<%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) do %>
<!-- This content will be replaced once the component connects -->
2014/06/01 13:05
<% end %>