将 Unix 时间戳转换为小时
所有,
我有一个数据库字段,它实际上计算从测验开始到当前时间所花费的时间。这是在某个时间点完成的(记录为当前时间),现在我有一个 Unixtimestamp 值
,即假设开始时间为 5/5/2011 1pm,当前时间填充为 5/5/2011 2pm。因此计算差异并将其存储为 Unix 时间戳。
现在我不知道这实际上是什么时候完成的,现在我必须回到花在参加测验上的时间。因此,这里需要将 Unix 时间戳转换回小时,在本例中返回 1 小时。谁能帮我理解如何做到这一点?
All,
I have a database field which actually computes the time spent from the time the quiz started to the current time. This was done at some point of time (recorded as current time) and now I have an Unixtimestamp value for it
i.e. Suppose the start time was 5/5/2011 1pm and the current time was populated at 5/5/2011 2pm. So the difference is calculated and stored as an Unix timestamp.
Now I don't know when this was actually done and now I have to revert back to hours spent taking the quiz. So here a Unix timestamp needs to be converted back to hours, in this case return 1 hour. Can anyone please help me understand how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你有时间,所以就做类似的事情
You have the seconds, so just do something like
下面是查找两个时间戳之间的天数差异的示例。
要转换为小时,请将 86400 改为 3600。
希望这有帮助。
Here is an example of finding the difference between two timestamps in days.
To convert to hours, instead of 86400 put 3600 instead.
Hope this helps.