hugo/content/en/functions/now.md
Bjørn Erik Pedersen b239595af5 Squashed 'docs/' changes from 0fd7b4169..501c6e233
501c6e233 Remoe speakerdeck example
9529bd27d Fix typos
530f22cd3 Remove language assuming knowledge of GitHub OAuth
c618809e7 Refer to Go by its proper name, not its domain name
06e23168b Add timeout parameter to configuration docs
034fa62a7 Update shortcodes.md
10ea79335 Document .Ordinal on shortcode
0bfd85fb9 Formatting
e44f80fdf Release 0.41
76164258c releaser: Add release notes to /docs for release of 0.41
8d87505eb releaser: Bump versions for release of 0.41
2bbc003ee docs: Document the GDPR Privacy Config
e2d11564d Merge commit 'd2b1030060d3c91d5f9ffa3456418da16bd74f1d'

git-subtree-dir: docs
git-subtree-split: 501c6e23370fae21e2110e0d7ea0db6731b31779
2018-06-11 22:31:02 +02:00

1.2 KiB
Raw Blame History

title linktitle description godocref date publishdate lastmod categories menu keywords signature workson hugoversion relatedfuncs deprecated aliases
now now Returns the current local time https://godoc.org/time#Time 2017-02-01 2017-02-01 2017-04-30
functions
docs
parent
functions
dates
time
now
Unix
dateFormat
false

See time.Time.

For example, building your site on June 24, 2017, with the following templating:

<div>
    <small>&copy; {{ now.Format "2006"}}</small>
</div>

would produce the following:

<div>
    <small>&copy; 2017</small>
</div>

The above example uses the .Format function, which page includes a full listing of date formatting using Go's layout string.

{{% note %}} Older Hugo themes may still be using the obsolete Pages .Now (uppercase with leading dot), which causes build error that looks like the following:

ERROR ... Error while rendering "..." in "...": ...
executing "..." at <.Now.Format>:
can't evaluate field Now in type *hugolib.PageOutput

Be sure to use now (lowercase with no leading dot) in your templating. {{% /note %}}