1. Handlebars Helpers
  2. Sugartime

Handlebars Helpers

Sugartime

Save a date using sugartime syntax

Overview

This helper outputs a date in a specified format according to the human time explanation.
It uses the Sugar.js Date library to parse the human date text.
You can use the interactive tool the this page to test the human date text.

The format uses the moment.js format.

When concatenating more than one human time phrase, ensure each phrase is separated by a coma.

Concatenating

Concatenating, stringing more that one phrase together, allows you to do quite complex sugartime calculations.

It calculates working from left to right, starting with the left most phrase. The result of the first phrase calculation is used as the starting point for the 2 second phrase calculation. It will continue until there is nothing left to calculate.

Syntax

        "{{#sugartime '[human date text]' '[, optional date text to concat separated by a coma]'}}[optional format]{{/sugartime}}"

      

Basic Example

Basic example will output the date in default format "YYYY-MM-DD HH:mm:SS" according to the human time explanation.

Usage

loading...

Substitution

loading...

Concat Example

Concat example will output the date in default format "YYYY-MM-DD HH:mm:SS" according to the human time explanation that is given in parts

Usage

loading...

Substitution

loading...

Format Example

Format example will output the date in a specified format "YYYY-MM-DD".

Usage

loading...

Substitution

loading...