Discuz! BBS

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 831|回复: 0

10位时间戳(13位时间戳)转换为日期

[复制链接]

254

主题

363

帖子

2435

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2435
发表于 2023-7-14 06:34:19 | 显示全部楼层 |阅读模式
10位是秒,13位是毫秒,16位是微秒,
注意后两种表示: unit='ms',  而第三种表示成毫秒也要除以1000

10位:https://blog.csdn.net/Student_WangJX/article/details/123231562
13位,16位:https://zhuanlan.zhihu.com/p/88106136?utm_id=0

见 example_timestamp.py:
  1. from pandas import to_datetime
  2. #print(pd.Timestamp(1303608600))
  3. from pandas.api.types import is_numeric_dtype
  4. timenum = 1303060000
  5. if is_numeric_dtype(type(timenum)):
  6.     print(to_datetime(timenum, unit='s').strftime('%Y-%m-%d %H:%M:%S'))
  7. else:
  8.     print("number error")
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-4-16 10:56 , Processed in 0.013990 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表