24 lines
715 B
Go
24 lines
715 B
Go
// timex 包示例:时间日期工具(NT/UTC 时间戳互转、时间字符串转毫秒时间戳、月份天数)
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.zeroonesoft.cn/golib/zogo/timex"
|
|
)
|
|
|
|
func main() {
|
|
// Windows NT 时间戳与 Unix 时间戳互转
|
|
nt := timex.UtcToNt(1000000000)
|
|
fmt.Println("Unix 转 NT:", nt)
|
|
fmt.Println("NT 转 Unix:", timex.NtToUtc(nt))
|
|
|
|
// 时间字符串转毫秒时间戳
|
|
ts, err := timex.TimeStrToTimestamp("2026-08-29 12:00:00")
|
|
fmt.Println("时间字符串转毫秒时间戳:", ts, "错误:", err)
|
|
|
|
// 查询指定年月有多少天
|
|
fmt.Println("2026年2月天数:", timex.GetYearMonthToDay(2026, 2))
|
|
fmt.Println("2024年2月天数:", timex.GetYearMonthToDay(2024, 2))
|
|
}
|