传入一个时间戳,以天时分秒格式打印出时间差

输入一个10位的时间戳,求出时间差

def time_diff(timestamp):
onlineTime = datetime.datetime.fromtimestamp(timestamp)
localTime = datetime.datetime.now()
result = localTime - onlineTime
hours = int(result.seconds / 3600)
minutes = int(result.seconds % 3600 / 60)
seconds = result.seconds%3600%60
print("当前网络时间:{0}".format(localTime))
print("上次在线时间:{0}".format(onlineTime))
print("{0}天{1}时{2}分{3}秒前在线".format(result.days,hours,minutes,seconds)) times = int(time.time())-80
time_diff(times)

运行效果:

当前网络时间:2020-05-27 18:00:03.393412

上次在线时间:2020-05-27 17:58:43

0天0时1分20秒前在线

最新文章

  1. 【WCF】使用“用户名/密码”验证的合理方法
  2. Java类变量和成员变量初始化过程
  3. mac 终端常用命令
  4. 知方可补不足~row_number,rank,dense_rank,ntile排名函数的用法
  5. Android中的五大布局和logcat打印日志
  6. maven使用入门(pom)
  7. 绑定本地Service并与之通信-----之二
  8. Js验证userAgent是否来自手机端
  9. delphi数字签名验证及能够获取数字签名文件信息(利用wintrust.dll的导出函数,翻译一下)
  10. jquery mobile左右滑动切换页面
  11. Asp.net网站的简单发布
  12. Hibernate一级缓存(基于查询分析)
  13. codeforces 8c Looking for Order
  14. 4.ElasticSearch的基本api操作
  15. Spark2.X管理与开发
  16. 【洛谷P1429】平面最近点对
  17. udp用户数据报协议
  18. JVM内存初学 堆、栈、方法区
  19. 第一个Sprint冲刺成果
  20. javascript深度克隆对象

热门文章

  1. git init 后关联github仓库是发生错误:
  2. Redux:Reducers
  3. MVC4.0 上传文件
  4. redis学习——day02_redis数据类型
  5. PAT-1132 Cut Integer (整数分割)
  6. 1、JavaScript中的Cookie 用于存储 web 页面的用户信息。
  7. A + B Problem(hdu1000)
  8. 洛谷 P1352 没有上司的舞会 树形DP板子
  9. Java IO(九)FilterInputStream 和 FilterOutputStream
  10. Java和NodeJS解析XML对比