2018-06-21 11:44:58 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-04-03 00:03:46 +08:00
|
|
|
"fmt"
|
|
|
|
"time"
|
2019-07-29 21:01:19 +08:00
|
|
|
|
|
|
|
"github.com/gogf/gf/os/glog"
|
|
|
|
"github.com/gogf/gf/os/gtime"
|
2018-06-21 11:44:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-04-03 00:03:46 +08:00
|
|
|
array := []string{
|
|
|
|
"2017-12-14 04:51:34 +0805 LMT",
|
|
|
|
"2006-01-02T15:04:05Z07:00",
|
|
|
|
"2014-01-17T01:19:15+08:00",
|
|
|
|
"2018-02-09T20:46:17.897Z",
|
|
|
|
"2018-02-09 20:46:17.897",
|
|
|
|
"2018-02-09T20:46:17Z",
|
|
|
|
"2018-02-09 20:46:17",
|
|
|
|
"2018.02.09 20:46:17",
|
|
|
|
"2018-02-09",
|
|
|
|
"2017/12/14 04:51:34 +0805 LMT",
|
|
|
|
"2018/02/09 12:00:15",
|
|
|
|
"01/Nov/2018:13:28:13 +0800",
|
|
|
|
"01-Nov-2018 11:50:28 +0805 LMT",
|
|
|
|
"01-Nov-2018T15:04:05Z07:00",
|
|
|
|
"01-Nov-2018T01:19:15+08:00",
|
|
|
|
"01-Nov-2018 11:50:28 +0805 LMT",
|
|
|
|
"01/Nov/2018 11:50:28",
|
|
|
|
"01/Nov/2018:11:50:28",
|
|
|
|
"01.Nov.2018:11:50:28",
|
|
|
|
"01/Nov/2018",
|
|
|
|
}
|
|
|
|
cstLocal, _ := time.LoadLocation("Asia/Shanghai")
|
|
|
|
for _, s := range array {
|
|
|
|
if t, err := gtime.StrToTime(s); err == nil {
|
2019-04-05 23:31:14 +08:00
|
|
|
fmt.Println(s)
|
|
|
|
fmt.Println(t.UTC().String())
|
2019-04-03 00:03:46 +08:00
|
|
|
fmt.Println(t.In(cstLocal).String())
|
|
|
|
} else {
|
2019-04-05 23:31:14 +08:00
|
|
|
glog.Error(s, err)
|
2019-04-03 00:03:46 +08:00
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
}
|
2018-06-21 11:44:58 +08:00
|
|
|
}
|