脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - python整小时 整天时间戳获取算法示例

python整小时 整天时间戳获取算法示例

2021-05-30 00:46JNeuman Python

今天小编就为大家分享一篇python整小时 整天时间戳获取算法示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

根据当前时间戳获得整小时时间戳

?
1
2
unit = 3600
start_time = int(time.time())/3600 * 3600

根据当前时间戳获得整天时间戳

?
1
2
unit = 3600*24
start_time = int(time.time()) / unit * unit - 8 * 3600

由于时间戳起始为1970 年 1 月 1 日(08:00:00)所以这里需要减8小时才时0点的时间戳

PS;推荐一款在线时间戳转换工具  https://tool.zzvips.com/t/timestamp/

以上这篇python整小时 整天时间戳获取算法示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/wangxin6722513/article/details/78564068

延伸 · 阅读

精彩推荐