Standard library / time

time.Duration.String()

Format a human-readable duration, using appropriate units. It is not a calendar date or a localized string. Expected stdout: '1m30s\n'.

Formal Syntax & Structure

go syntaxgo
func (d Duration) String() string

Return Value

string

Format a human-readable duration, using appropriate units.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func main() { fmt.Println((90 * time.Second).String()) }
Go Reference