»
14. Date Time Type
Go语言中的时间类型在time包中。具体的应用为:
import (
"fmt"
"time"
)
currentTime := time.Now()
//格式化的模板为Go的诞生时间2006年1月2号15点04分05秒 Mon Jan
fmt.Println(now.Format("2006-01-02 15:04:05.000 Mon Jan"))
//也就是在Go的格式模板中2006表示年份,01表示月份,02表示日期,15表示小时,04表示分钟,05表示秒数,000表示毫秒数,Mon表示星期英文名缩写,Jan表示月份英文名缩写
//下面的语句输出当前时间的年月日
fmt.Println(now.Format("2006/01/02"))
————www.v-signon.com学习者共勉