📜  Python 不能减去 offset-naive 和 offset-aware 日期时间 - Python Code Example

📅  最后修改于: 2022-03-11 14:45:20.246000             🧑  作者: Mango

代码示例1
import dateutil, datetime, pytz
LastDate = dateutil.parser.parse('2020-06-06 00:00:00+00:00')
now = datetime.datetime.now()
# Remove the TimeZone extension.
if (now - LastDate.replace(tzinfo=None) ).days >1:
    print("This works")
# OR, make current datetime aware of the timezone
now = pytz.utc.localize(now)
if (now - LastDate ).days >1:
    print("This works too")