From b33bfd40bed7af36faba18bed09efb6b95c58192 Mon Sep 17 00:00:00 2001 From: Wade Fitzpatrick Date: Mon, 8 Aug 2016 11:38:18 +1000 Subject: [PATCH] docs: Add doc for time template func --- docs/content/templates/functions.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/content/templates/functions.md b/docs/content/templates/functions.md index 9f4499388..1df0a80f8 100644 --- a/docs/content/templates/functions.md +++ b/docs/content/templates/functions.md @@ -741,6 +741,16 @@ This can be useful if you want to use Gravatar for generating a unique avatar: ``` +## Times + +### time + +`time` converts a timestamp string into a [`time.Time`](https://godoc.org/time#Time) structure so you can access its fields. E.g. + +* `{{ time "2016-05-28" }}` → "2016-05-28T00:00:00Z" +* `{{ (time "2016-05-28").YearDay }}` → 149 +* `{{ mul 1000 (time "2016-05-28T10:30:00.00+10:00").Unix }}` → 1464395400000 (Unix time in milliseconds) + ## URLs