Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang program to demonstrate the Minutes() function

Here, we are going to demonstrate the Minutes() function in Golang (Go Language).
Submitted by Nidhi, on March 22, 2021 [Last updated : March 04, 2023]

Minutes() function in Golang

Problem Solution:

In this program, we will demonstrate the Minutes() function to get the total minutes in floating-point format by specifying the time in a specific format.

Program/Source Code:

The source code to demonstrate the Minutes() function is given below. The given program is compiled and executed successfully.

Golang code to demonstrate the example of Minutes() function

// 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())


Total Minutes are: 212.500000


In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt and time packages to use time and fmt related functions.

In the main() function, 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. After that, we printed the result on the console screen.

Golang Date & Time Programs »

Related Programs

Comments and Discussions!

Load comments ↻

Copyright © 2024 www.includehelp.com. All rights reserved.