0
我有两个日期时间变量,需要在几秒钟内找出它们之间的差异。因为我不能像Python一样使用datetime.strptime
,我应该使用什么?如何计算IronPython中两个日期之间的差异?
day1=('2016-10-28 08:11:36')
day2=('2016-10-28 10:32:45')
我有两个日期时间变量,需要在几秒钟内找出它们之间的差异。因为我不能像Python一样使用datetime.strptime
,我应该使用什么?如何计算IronPython中两个日期之间的差异?
day1=('2016-10-28 08:11:36')
day2=('2016-10-28 10:32:45')
所以我完全偷这从Tibco的社区论坛Sean Riley,但如果他出现,我会删除这一点,并给他点。
问题在于Spotfire使用旧版本的IronPython。 strptime
现在位于DateTime库中,而它位于Time库中。所以这让我到了我想成为的地方。
import datetime, time
day1=datetime.datetime.now()
day2=('2016-10-28 10:32:45')
day2=datetime.datetime(*time.strptime(day2, "%Y-%m-%d %H:%M:%S")[:6])
print abs(day2-day1).seconds