time.Now()
time.Now()
time.Now()
// Golang program to get the current time
package main
  
// Here "fmt" is formatted IO which
// is same as C’s printf and scanf.
import "fmt"
  
// importing time module
import "time"
  
// Main function
func main() {
  
    // Using time.Now() function.
    dt := time.Now()
    fmt.Println("Current date and time is: ", dt.String())
}

输出 :

Current date and time is:  2009-11-10 23:00:00 +0000 UTC m=+0.000000001

示例#2:

// Golang program to get the current time
package main
  
// Here "fmt" is formatted IO which
// is same as C’s printf and scanf.
import "fmt"
  
// importing time module
import "time"
  
// Main function
func main() {
  
    // Using time.Now() function.
    dt := time.Now()
    fmt.Println(dt.Format("01-02-2006 15:04:05"))
  
}

输出:

11-10-2009 23:00:00