golang 获取明天零点的时间戳示例
时间:2021-06-11 08:06:40|栏目:Golang|点击: 次
实例如下所示:
package main
import (
"fmt"
"time"
)
func main() {
timeStr := time.Now().Format("2006-01-02")
fmt.Println(timeStr)
//使用Parse 默认获取为UTC时区 需要获取本地时区 所以使用ParseInLocation
t, _ := time.ParseInLocation("2006-01-02 15:04:05", timeStr+" 23:59:59", time.Local)
t2, _ := time.ParseInLocation("2006-01-02", timeStr, time.Local)
fmt.Println(t.Unix() + 1)
fmt.Println(t2.AddDate(0, 0, 1).Unix())
}
上一篇:利用Go语言追加内容到文件末尾
栏 目:Golang
本文标题:golang 获取明天零点的时间戳示例
本文地址:http://www.codeinn.net/misctech/139552.html






