Template helper moment

handlebars.moment

Outputs a date

Current date

{{moment}}

Specific date

{{moment d}}
{{moment date=d}}

Date format

{{moment d "YY, MMM dd"}}
{{moment date=d format="DD/MM/YYYY"}}
{{moment d unix=true}}

Date input parsing

{{moment dinput input="DD-YYYY-MM"}}

Date timezone

{{moment dstr utc=true}}
{{moment dstr local=true}}

Date units

{{moment d "millisecond"}}
{{moment d "second"}}
{{moment d "minute"}}
{{moment d "hour"}}
{{moment d "date"}}
{{moment d "day"}}
{{moment d "weekday"}}
{{moment d "weekday" type="s"}}
{{moment d "weekday" type="xs"}}
{{moment d "weekday" type="number"}}
{{moment d "isoweekday"}}
{{moment d "dayofyear"}}
{{moment d "week"}}
{{moment d "isoweek"}}
{{moment d "month"}}
{{moment d "year"}}
{{moment d "weekyear"}}
{{moment d "isoweekyear"}}

Date manipulation

{{moment d add="days" amount="7"}}
{{moment d add="365" addparam="d"}}
{{moment d subtract="days" amount="7"}}
{{moment d subtract="365" subtractparam="d"}}

Start and end of years

{{moment d startof="year"}}
{{moment d endof="year"}}

Date max/min

{{moment d max=dmax}}
{{moment d min=dmin}}

Date from now and specific dates

{{moment d "fromNow"}}
{{moment d "from" dfrom}}

Difference between dates

{{moment d diff=ddiff}}

Date as calendar time

{{moment d "calendar"}}

Date as strings

{{moment d "str"}}
{{moment d "val"}}
{{moment d "unix"}}

Moment utils

{{moment d "daysinmonth"}}
{{moment d "todate"}}
{{moment d "array"}}
{{moment d "isostring"}}

Helper parameters map to those of Moment.js unless noted

Source:
Parameters:
Name Type Attributes Description
0 string | date <optional>

Date string|object

1 string <optional>

Date format / Moment method

2 * <optional>

Moment method params

3 * <optional>

Moment method params 1

4 * <optional>

Moment method params 2

date string | date <optional>

Alternative date

format string <optional>

Alternative format

input string <optional>

Format to use to parse date

lang string <optional>

Specific locale to use

type number | string <optional>

Type of weekday (L|S|XS|number)

suffix boolean <optional>
utc boolean <optional>
local boolean <optional>
from string <optional>
unixfrom string <optional>
max string <optional>
min string <optional>
unixmax string <optional>
unixmin string <optional>
startOf string <optional>
endOf string <optional>
add number | string <optional>
subtract number | string <optional>
addparam number <optional>

Value to use if add is number

subtractparam number <optional>

Value to use if subtract is number

amount number <optional>

Value to use if add|subtract are strings

diff string <optional>
unixdiff string <optional>
unitdiff string <optional>

Value for Moment method params 1 if diff

nosuffix boolean <optional>

Value for Moment method params 2 if diff