golang的time.Format設計的和其他語言都不一樣, 其他語言總是使用一些格式化字符進行標示, 而golang呢, 查了網上一些坑例子 自己查了下golang的源碼, 發現以下代碼
// String returns the time formatted using the format string
// "2006-01-02 15:04:05.999999999 -0700 MST"
func (t Time) String() string {
return t.Format("2006-01-02 15:04:05.999999999 -0700 MST")
}
嘗試將2006-01-02 15:04:05寫入到自己的例子中
func nowTime() string {
return time.Now().Format("2006-01-02 15:04:05")
}
結果返回正確. 詢問了下, 據說這個日期是golang誕生的日子… 咋那么自戀呢…