Skip to content Skip to footer navigation

Format Time Modifier

Given a time string, format_time will format it using PHP's datetime format variables.

start_time: 13:45
{{ start_time | format_time }}
{{ start_time | format_time('g:ia') }}
{{ start_time | format_time('h:iA') }}
{{ Statamic::modify($start_time)->format_time() }}
{{ Statamic::modify($start_time)->format_time('g:ia') }}
{{ Statamic::modify($start_time)->format_time('h:iA') }}
1:45pm
1:45pm
01:45PM

Parameters#

You can technically use any date formatting variables, but only the time-related really ones make sense here.

Value Description Example
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
g 12-hour format of an hour without leading zeros 1 to 12
G 24-hour format of an hour without leading zeros 0 to 23
h 12-hour format of an hour with leading zeros 01 to 12
H 24-hour format of an hour with leading zeros 00 to 23
i Minutes with leading zeros 00 to 59
s Seconds with leading zeros 00 to 59