parser 字串成 time 變數, 尤其是處理用時間當檔名的檔案
str := "201501042030"
t, _ := time.Parse("200601021504", str)
其中他的字串切割方式比較不同
如果是 Qt parse 時間的 layout 是 "yyyyMMdd hh:mm:ss"
在 go 則是 "20060102 03:04:05"
另外有其他的關鍵字 可以從中組合符合你所要要的 layout
const (
stdLongMonth = "January"
stdMonth = "Jan"
stdNumMonth = "1"
stdZeroMonth = "01"
stdLongWeekDay = "Monday"
stdWeekDay = "Mon"
stdDay = "2"
stdUnderDay = "_2"
stdZeroDay = "02"
stdHour = "15"
stdHour12 = "3"
stdZeroHour12 = "03"
stdMinute = "4"
stdZeroMinute = "04"
stdSecond = "5"
stdZeroSecond = "05"
stdLongYear = "2006"
stdYear = "06"
stdPM = "PM"
stdpm = "pm"
stdTZ = "MST"
stdISO8601TZ = "Z0700" // prints Z for UTC
stdISO8601ColonTZ = "Z07:00" // prints Z for UTC
stdNumTZ = "-0700" // always numeric
stdNumShortTZ = "-07" // always numeric
stdNumColonTZ = "-07:00" // always numeric
)
時間的加減, 時間加上8小時
t = t.Add(time.Hour * time.Duration(8) )
sleep 也定義在 time 裡面, 以下是 sleep 100 ms
time.Sleep(100 * time.Millisecond)
.