1 回答

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個(gè)贊
使用時(shí)間。解析In位置
,用于在沒(méi)有給定時(shí)區(qū)時(shí)解析給定位置中的時(shí)間。 是您當(dāng)?shù)氐臅r(shí)區(qū),請(qǐng)將其作為您的位置傳遞。time.Local
package main
import (
"fmt"
"time"
)
func main() {
// This will honor the given time zone.
// 2012-07-09 05:02:00 +0000 CEST
const formWithZone = "Jan 2, 2006 at 3:04pm (MST)"
t, _ := time.ParseInLocation(formWithZone, "Jul 9, 2012 at 5:02am (CEST)", time.Local)
fmt.Println(t)
// Lacking a time zone, it will use your local time zone.
// Mine is PDT: 2012-07-09 05:02:00 -0700 PDT
const formWithoutZone = "Jan 2, 2006 at 3:04pm"
t, _ = time.ParseInLocation(formWithoutZone, "Jul 9, 2012 at 5:02am", time.Local)
fmt.Println(t)
}
- 1 回答
- 0 關(guān)注
- 88 瀏覽
添加回答
舉報(bào)