英文:
Time getting printed as '0x814ff30'
问题
学习Go语言。可能是一个基础问题。
我有一个time.Time对象,我想要获取它的纪元时间。我写的代码是:
fmt.Println(startTime.Unix)
其中startTime是一个time.Time对象。现在,我本来期望它会打印出一个很大的数字,比如1257894000,但实际上我得到的是:0x814ff30。
不明白为什么会这样?如果不清楚的话,我可以提供更多信息。
英文:
Learning go lang. Might be a basic question.
I have an time.Time object and I wanted to get the epoch time for it. What I write to get that is :
fmt.Println(startTime.Unix)
where startTime is an object of time.Time. Now, I would have expected it to print some big number, something as, 1257894000, but what I get is : 0x814ff30.
Did not understand why? Would be happy to write more in case it is not clear.
答案1
得分: 1
使用time.Unix()
函数
fmt.Println(time.Now().Unix())
//1479454089
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论