Debian Codegraph @

docs/content/en/functions/time/Now.md

raw
1 ---
2 title: time.Now
3 description: Returns the current local time.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [now]
9 returnType: time.Time
10 signatures: [time.Now]
11 aliases: [/functions/now]
12 ---
13
14 For example, when building a site on October 15, 2023 in the America/Los_Angeles time zone:
15
16 ```go-html-template
17 {{ time.Now }}
18 ```
19
20 This produces a `time.Time` value, with a string representation such as:
21
22 ```text
23 2023-10-15 12:59:28.337140706 -0700 PDT m=+0.041752605
24 ```
25
26 To format and [localize](g) the value, pass it through the [`time.Format`][] function:
27
28 ```go-html-template
29 {{ time.Now | time.Format "Jan 2006" }} → Oct 2023
30 ```
31
32 The `time.Now` function returns a `time.Time` value, so you can chain any of the [time methods][] to the resulting value. For example:
33
34 ```go-html-template
35 {{ time.Now.Year }} → 2023 (int)
36 {{ time.Now.Weekday.String }} → Sunday
37 {{ time.Now.Month.String }} → October
38 {{ time.Now.Unix }} → 1697400955 (int64)
39 ```
40
41 [`time.Format`]: /functions/time/format/
42 [time methods]: /methods/time/