github.com/rabbouni145/gg@v0.47.1/docs/content/en/functions/time.md (about)

     1  ---
     2  title: time
     3  linktitle:
     4  description: Converts a timestamp string into a `time.Time` structure.
     5  godocref:
     6  date: 2017-02-01
     7  publishdate: 2017-02-01
     8  lastmod: 2017-02-01
     9  categories: [functions]
    10  menu:
    11    docs:
    12      parent: "functions"
    13  keywords: [dates,time]
    14  signature: ["time INPUT"]
    15  workson: []
    16  hugoversion:
    17  relatedfuncs: []
    18  deprecated: false
    19  aliases: []
    20  ---
    21  
    22  `time` converts a timestamp string into a [`time.Time`](https://godoc.org/time#Time) structure so you can access its fields:
    23  
    24  ```
    25  {{ time "2016-05-28" }} → "2016-05-28T00:00:00Z"
    26  {{ (time "2016-05-28").YearDay }} → 149
    27  {{ mul 1000 (time "2016-05-28T10:30:00.00+10:00").Unix }} → 1464395400000, or Unix time in milliseconds
    28  ```
    29  
    30  ## Example: Using `time` to get Month Index
    31  
    32  The following example takes a UNIX timestamp---set as `utimestamp: "1489276800"` in a content's front matter---converts the timestamp (string) to an integer using the [`int` function][int], and then uses [`printf`][] to convert the `Month` property of `time` into an index. 
    33  
    34  The following example may be useful when setting up [multilingual sites][multilingual]:
    35  
    36  {{< code file="unix-to-month-integer.html" >}}
    37  {{$time := time (int .Params.addDate)}}
    38  => $time = 1489276800
    39  {{$time.Month}}
    40  => "March"
    41  {{$monthindex := printf "%d" $time.Month }}
    42  => $monthindex = 3
    43  {{< /code >}}
    44  
    45  
    46  [int]: /functions/int/
    47  [multilingual]: /content-management/multilingual/
    48  [`printf`]: /functions/printf/