Back to Hugo

time.Duration

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

0.161.1664 B
Original Source

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

This template:

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

Is rendered to:

text
There are 86400 seconds in one day.

The time unit must be one of the following:

DurationValid time units
hourshour, h
minutesminute, m
secondssecond, s
millisecondsmillisecond, ms
microsecondsmicrosecond, us, µs
nanosecondsnanosecond, ns