hugo/content/en/functions/time/Duration.md
Bjørn Erik Pedersen 9b0050e9aa Squashed 'docs/' content from commit 5c085a37b
git-subtree-dir: docs
git-subtree-split: 5c085a37b297bf12f59efeaae591418ec025c10d
2024-01-27 10:48:33 +01:00

1 KiB

title description categories keywords action aliases
time.Duration Returns a time.Duration value using the given time unit and number.
aliases related returnType signatures
duration
functions/time/AsTime
functions/time/Format
functions/time/Now
functions/time/ParseDuration
time.Duration
time.Duration TIME_UNIT NUMBER
/functions/duration

The time.Duration function returns a time.Duration value that you can use with any of the Duration methods.

This template:

{{ $duration := time.Duration "hour" 24 }}
{{ printf "There are %.0f seconds in one day." $duration.Seconds }}

Is rendered to:

There are 86400 seconds in one day.

The time unit must be one of the following:

Duration Valid time units
hours hour, h
minutes minute, m
seconds second, s
milliseconds millisecond, ms
microseconds microsecond, us, µs
nanoseconds nanosecond, ns