首页 > 解决方案 > 了解两个 ISO 8061 时间之间的区别

问题描述

无法理解 ISO 8061 中两个时间戳之间的区别:

我有两个字符串:

alert_time
'2019-08-21T22:05:59.605Z'

current_time
'2019-08-21T22:06:58'

我更改了 alert_time 变量以匹配 current_time 的格式

alert_time = alert_time[:-5]

alert_time
'2019-08-21T22:05:59'

现在我想看看它们之间的区别

datetimeFormat = '%Y-%m-%dT%H:%M:%S'
 diff = datetime.datetime.strptime(alert_time, datetimeFormat) - datetime.datetime.strptime(current_time, datetimeFormat)

diff
datetime.timedelta(-1, 86341)

那个输出是什么意思?我正在寻找能在几秒钟内告诉我差异的东西

标签: python

解决方案


推荐阅读