mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Merge commit 'da16527896d3087585c5e758083ea498dcabc2c3'
This commit is contained in:
20
docs/content/en/functions/time.ParseDuration.md
Normal file
20
docs/content/en/functions/time.ParseDuration.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: time.ParseDuration
|
||||
description: Parses a given duration string into a `time.Duration` structure.
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
keywords: [time parse duration]
|
||||
signature: ["time.ParseDuration DURATION"]
|
||||
hugoversion:
|
||||
aliases: []
|
||||
---
|
||||
|
||||
`time.ParseDuration` parses a duration string into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields.
|
||||
A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as `300ms`, `-1.5h` or `2h45m`. Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`.
|
||||
|
||||
You can perform [time operations](https://pkg.go.dev/time#Duration) on the returned `time.Duration` value:
|
||||
|
||||
{{ printf "There are %.0f seconds in one day." (time.ParseDuration "24h").Seconds }}
|
||||
<!-- Output: There are 86400 seconds in one day. -->
|
Reference in New Issue
Block a user