//年月日轉時間戳
//待轉化為時間戳的字符串?注意?這里的小時和分鐘還要秒必須寫?因為是跟著模板走的?修改模板的話也可以不寫??
location??toBeCharge?:=?"2015-01-01?00:00:00"? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
??//轉化所需模板??
timeLayout?:=?"2006-01-02?15:04:05"? ? ? ? ?
//重要:獲取時區?
loc,?_?:=?time.LoadLocation("Local")? ? ? ? ? ?
//使用模板在對應時區轉化為time.time類型
theTime,?_?:=?time.ParseInLocation(timeLayout,?toBeCharge,?loc)? ??
//轉化為時間戳?類型是int64??
sr?:=?theTime.Unix()? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
?//打印輸出theTime?2015-01-01?15:15:00?+0800?CST?
fmt.Println(theTime)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
?//打印輸出時間戳?1420041600
?fmt.Println(sr)? ??
//時間戳轉日期??
//設置時間戳?使用模板格式化為日期字符串
dataTimeStr?:=?time.Unix(sr,?0).Format(timeLayout)??
fmt.Println(dataTimeStr)??