I want to return the current time in a format in go, I have no trouble in format the time, but when return it as string in a func, I got stucked:
package main
import (
"fmt"
"time"
)
func getCurrentTime()string{
t := time.Now().Local()
return fmt.Sprintf("%s", t.Format("2006-01-02 15:04:05 +0800"))
}
func main() {
fmt.Println("current Time is:",getCurrentTime)
t := time.Now().Local()
fmt.Println("current Time is:", t.Format("2006-01-02 15:04:05 +0800"))
}
The out put is :
current Time is: 0x400c00
current Time is: 2015-01-16 12:45:33 +0800
instead of
current Time is: 2015-01-16 12:45:33 +0800
current Time is: 2015-01-16 12:45:33 +0800
which I expected.