Q:

Golang program to demonstrate the Minutes() function

belongs to collection: Golang Date & Time Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

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

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

Output:

Total Minutes are: 212.500000

Explanation:

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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Golang Date & Time Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Golang program to demonstrate the Nanoseconds() fu... >>
<< Golang program to demonstrate the hours() function...