最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Python中判断两个datetime的时间间隔超过多少秒

Python crifan 4436浏览 0评论

参考:

8.1. datetime — Basic date and time types — Python 2.7.12 documentation

Python-基础-时间日期处理小结

Python timedelta – 我的成长之路 http://foofish.net – ITeye技术网站

好像是:

        curDatetimeDelta = curDatetime – updateLocationTime
        gLog.debug(“curDatetimeDelta=%s”, curDatetimeDelta)
        pastSeconds = curDatetimeDelta.total_seconds()
        gLog.debug(“pastSeconds=%s”, pastSeconds)

应该是的。

另外也有别人这么用:

<code>    @property
    def is_online(self):
        if not self.location:
            return False
        if (datetime.now() - self.location.updatedAt).total_seconds() &gt; 60:
            return False
        else:
            return True
</code>

转载请注明:在路上 » 【已解决】Python中判断两个datetime的时间间隔超过多少秒

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.162 seconds, using 22.03MB memory