hugo/docs/content/en/functions/time/Now.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

1.2 KiB

title description categories keywords action aliases
time.Now Returns the current local time.
aliases related returnType signatures
now
functions/time/AsTime
functions/time/Duration
functions/time/Format
functions/time/ParseDuration
time.Time
time.Now
/functions/now

For example, when building a site on October 15, 2023 in the America/Los_Angeles time zone:

{{ time.Now }}

This produces a time.Time value, with a string representation such as:

2023-10-15 12:59:28.337140706 -0700 PDT m=+0.041752605

To format and localize the value, pass it through the time.Format function:

{{ time.Now | time.Format "Jan 2006" }} → Oct 2023

The time.Now function returns a time.Time value, so you can chain any of the time methods to the resulting value. For example:

{{ time.Now.Year }} → 2023 (int)
{{ time.Now.Weekday.String }} → Sunday
{{ time.Now.Month.String }} → October
{{ time.Now.Unix }} → 1697400955 (int64)