docs: Add doc for time template func
authorWade Fitzpatrick <wade.fitzpatrick@gmail.com>
Mon, 8 Aug 2016 01:38:18 +0000 (11:38 +1000)
committerdigitalcraftsman <digitalcraftsman@protonmail.com>
Mon, 8 Aug 2016 10:28:41 +0000 (12:28 +0200)
docs/content/templates/functions.md

index 9f4499388f3368b4305b02585e3405899408eb54..1df0a80f83e556064c132e5b995d1cb7fa008ccc 100644 (file)
@@ -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