Toggle menu

Dates

Date manipulation. Includes "formatDate", "now" and "timeago".

formatDate

Formats a date into a string given a format. Formatting rules follow www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime

Parameters

format [string] - The format string (Required)

Example

date = "2017-05-31"

{{formatDate date "%m/%d/%Y"}}
{{formatDate date "%I:%M%p"}}
{{formatDate date "%F"}}
{{formatDate date "%Y%m%dT%H%M%S%z"}}

Result

05/31/2017
01:00AM
2017-05-31
20170531T010000+0001

now

Returns the current date.

Parameters

format [string] - The format string (Optional). Formatting rules follow www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime

Example

{{now}}
{{now "%m/%d/%Y"}}

Result

Wed May 31 2017 16:05:37 GMT+0100 (GMT Daylight Time)
05/31/2017

timeago

Returns a human-readable time phrase from the given date. Counts from midnight UTC.

Parameters

None

Example

date = "2017-05-31" (and today is 31/05/2017 at 16:07)

{{timeago date}}

Result

"15 hours ago"

Last modified on May 31, 2022

Share this page

Facebook icon Twitter icon email icon

Print

print icon