1 回答

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊
以下代碼應(yīng)該有所幫助。我已經(jīng)評(píng)論了代碼以便更好地理解。
package main
import (
"fmt"
"os"
"time"
)
func main() {
// Get the timezone
zone, offset := time.Now().Zone()
// Get the location
var loc = time.FixedZone(zone, offset)
// Reference format: Mon Jan 2 15:04:05 -0700 MST 2006
t, err := time.ParseInLocation("2006-01-02 15:04:05", "2020-11-14 05:53:40", loc)
if err != nil {
fmt.Println("Error: ", err)
os.Exit(1)
}
// Print the timestamp in RFC3339 format
fmt.Println(t.Format(time.RFC3339))
}
- 1 回答
- 0 關(guān)注
- 134 瀏覽
添加回答
舉報(bào)