Field Helpers - Dates
-
dateFmt
-
dateFmtUK
-
dateFmtShort
-
timeFmt
-
now
- timeago
{{formatDate}}
Formats a date into a string given a format. Accepts any value that can be passed to new Date()
. This helper is a port of the formatDate-js library by Michael Baldry.
Parameters: format String
, required
The format string, according to these tokens: strftime
Given this data:
date = new Date()
And these templates:
{{formatDate date "%m/%d/%Y"}} {{formatDate date "%I:%M%p"}} {{formatDate date "%F"}} {{formatDate date "%Y%m%dT%H%M%S%z"}}
The output would be:
07/26/2012
11:38PM
2012-07-26
20120726T233805-0004
{{ {{now}}
Returns the current date.
Parameters: format String
- The format string, according to these tokens: http://www.ruby-doc.org/core-1.9.3/Time.html#method-i-strftime (Optional)
Template:
{{now}} {{now "%m/%d/%Y"}}
Renders to:
Thu Jul 26 2012 23:41:02 GMT-0400 (AST)
07/26/2012
{{ {{timeago}}
Returns a human-readable time phrase from the given date.
Parameters: none
Data:
date = 'Thu Jul 22 2012 23:41:02 GMT-0400 (AST)'
Template:
{{timeago date}}
Renders to:
4 days ago