字符串转时间一定要通过time.ParseInLocation,不能直接用Parse,如果是Parse直接转,二者会存在8小时时间差!!!

currentTime :=time.Now()
todayZero, _ :=time.ParseInLocation("2006-01-02 15:04:05", "2019-10-2115:22:22", time.Local)
subM := currentTime.Sub(todayZero)
fmt.Print(int(subM.Hours()))
fmt.Print(1111)

输出为2019-10-2115:22:22距目前时间的相差时间(毫秒)