在golang中获取日期,例如“ 2018-07-13” [重复]

This question already has an answer here:

how to get date in golang like this formate "2018-07-13"

main.go file

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println(time.Now())
}

$ go run main.go

otuput:

2018-07-13 21:25:16.796379489 +0500 +05 m=+0.000120455

how to write function to return date in string like this formate "2018-07-13"?

</div>

fmt.Println(time.Now().Format("2006-01-02"))

https://play.golang.org/p/AOrLRNkOxP_b

reference