Skip to content
Home » How to demonstrate the Minutes() function in Golang

How to demonstrate the Minutes() function in Golang

Learn about How to demonstrate the Minutes() function in Golang in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

How to demonstrate the Minutes() function in Golang

// Golang program to demonstrate the Minutes() function

package main

import "fmt"
import "time"

func main() {
	t, _ := time.ParseDuration("3h32m30s")
	fmt.Printf("Total Minutes are: %f", t.Minutes())
}

In the above program, we declare the package main. The main package instructs the Go language compiler that the package must be compiled and an executable file generated. We imported the fmt package, which contains the files of the fmt package, and then we can use a function related to the fmt package. Here, we created t variable initialized using time.ParseDuration() function. Then get total minutes in the floating-point format using Minutes() function. The Minutes() function returns float64 value.

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
How to demonstrate the Nanoseconds() function in Golang
How to demonstrate the Seconds() function in Golang