package main
import (
"fmt"
"time"
)
//1489248000
//2017-03-13 11:07:18
//1489374438
func main() {
//时间戳
fmt.Println(time.Now().Unix())
//英文时间
fmt.Println(time.Now())
//格式化时间-奇葩的时间点,其他时间点无效
fmt.Println(time.Now().Format("2017-01-02 12:12:12"))
fmt.Println(time.Now().Format("2006-01-02 15:04:05"))
//时间戳转str时间
fmt.Println(time.Unix(1489248000,0).Format("2006-01-02 15:04:05"))
//str时间转时间戳---方法一
aTime := time.Date(2017,03,13,11,07,18,0,time.Local)
fmt.Println(aTime.Unix())
fmt.Println(time.Unix(1489374438,0).Format("2006-01-02 15:04:05"))
//str时间转时间戳---方法二
bTime,err := time.Parse("2006-01-02 15:04:05","2017-03-13 11:07:18")
if err == nil {
fmt.Println(bTime.Unix())
}
}