python 实现UTC时间加减的方法

如下所示:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import datetime

time_delta = datetime.timedelta(hours=-2)
time_now = datetime.datetime.utcnow()
invalid_time = str(time_now + time_delta)[:19]

print invalid_time

相关推荐