Duration.Hours in Go

Posted by GoDoc
Last Edited by yhuang
Public (Editable by Users)

Hours returns the duration as a floating point number of hours.

Go
Edit
package main

import (
	"fmt"
	"time"
)

func main() {
	h, _ := time.ParseDuration("4h30m")
	fmt.Printf("I've got %.1f hours of work left.", h.Hours())
}