Standard library / time

time.Duration.Hours()

Express the duration as floating-point hours, including fractions. Expected stdout: '1.5\n'.

Formal Syntax & Structure

go syntaxgo
func (d Duration) Hours() float64

Return Value

float64

Express the duration as floating-point hours, including fractions.

Working Example

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