time_tag
Creates an HTML <time> tag from a timestamp.
Output formats can be referenced from the Ruby documentation.
Parameters
time{String}: The timestamp. This parameter is required.format{String}: The display format. This parameter is optional.hash.datetime{String}: The datetime attribute format. Optional, defaults toYYYY-MM-DDThh:mm:ssTZD.hash.format{String}: The display format. This parameter is optional.returns{String}: Returns an HTML string.
Usage
{{time_tag time format }}
Example
{{ time_tag article.created_at '%B %d, %Y' }}
Format
{{time_tag time string }}
{{time_tag time format=string }}
Specify the date format recognizable by the locale. You can use the following formats:
abbreviated_datebasicdatedate_at_timedefaulton_date
{{ time_tag article.created_at 'abbreviated_date' }}
datetime
The default format for the datetime attribute of the <time> tag is YYYY-MM-DDThh:mm:ssTZD. However, you can define a custom format using strftime shorthand formats.
{{time_tag time format datetime=format2 }}
{{ time_tag article.created_at 'abbreviated_date' datetime='%Y-%m-%d' }}
Was this article helpful to you?