golang 获取当天凌晨时间戳

星期三, 2019-04-10 | Author: Lee | golang | 12,079 views

使用golang的time函数,记得要设定系统的时区,否则数据有问题

设置centos系统时区为上海

timedatectl set-timezone Asia/Shanghai
import("fmt"
	"time")
func main(){
	t := time.Now()
	zero_tm := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()).Unix()
	fmt.Println(zero_tm)
}

Tags:

文章作者: Lee

本文地址: https://www.pomelolee.com/1865.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta