Duration.Seconds in Go

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

Seconds returns the duration as a floating point number of seconds.

Go
Edit
package main

import (
	"fmt"
	"time"
)

func main() {
	m, _ := time.ParseDuration("1m30s")
	fmt.Printf("Take off in t-%.0f seconds.", m.Seconds())
}