Answers for "how to intialize time.time in golang"

Go
1

time now golang int64

now := time.Now()      // current local time
sec := now.Unix()      // number of seconds since January 1, 1970 UTC
nsec := now.UnixNano() // number of nanoseconds since January 1, 1970 UTC

fmt.Println(now)  // time.Time
fmt.Println(sec)  // int64
fmt.Println(nsec) // int64
Posted by: Guest on January-23-2021
0

print time in golang

package main
  
import "fmt"
import "time"
  
func main() {
    dt := time.Now()
      
    // printing the time in string format
    fmt.Println("Current date and time is: ", dt.String())
}

//Output: 
//Current date and time is:  2020-05-05 06:43:01.419199824 +0000 UTC m=+0.000076701
Posted by: Guest on March-10-2022

Browse Popular Code Answers by Language