Skip to content
Related Articles

Related Articles

Improve Article

time.Time.Minute() Function in Golang With Examples

  • Last Updated : 21 Apr, 2020

In Go language, time packages supplies functionality for determining as well as viewing time. The Time.Minute() function in Go language is used to find the minute offset within the stated hour that is provided by “t” and the range is [0, 59]. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.

Syntax:

func (t Time) Minute() int

Here, “t” is the stated time.

Return Value: It returns the minute offset within the stated hour that is provided by “t”.

Example 1:






// Golang program to illustrate the usage of
// Time.Minute() function
  
// Including main package
package main
  
// Importing fmt and time
import "fmt"
import "time"
  
// Calling main
func main() {
  
    // Declaring t in UTC
    t := time.Date(2019, 6, 5, 11,
             35, 04, 0, time.UTC)
  
    // Calling Minute method
    min := t.Minute()
  
    // Prints minute as specified
    fmt.Printf("The stated minute within"+
     " the hour specified is: %v\n", min)
}

Output:

The stated minute within the hour specified is: 35

Example 2:




// Golang program to illustrate the usage of
// Time.Minute() function
  
// Including main package
package main
  
// Importing fmt and time
import "fmt"
import "time"
  
// Calling main
func main() {
  
    // Declaring t in UTC
    t := time.Date(2019, 6, 5,
       11, 91, 04, 0, time.UTC)
  
    // Calling Minute method
    min := t.Minute()
  
    // Prints minute as specified
    fmt.Printf("The stated minute within"+
       " the hour specified is: %v\n", min)
}

Output:

The stated minute within the hour specified is: 31

Here, the stated minute is out of usual range but it is normalized while conversion.




My Personal Notes arrow_drop_up
Recommended Articles
Page :