1.首先下载pytz
pytz的下载地址:
http://sourceforge.net/projects/pytz/
2.然后使用下面的代码:
from datetime import datetime
from datetime import date as strdate
from pytz import timezone
def now(tz = None):
if tz == None:
tz = timezone(“Asia/Shanghai”)
time = datetime.now(tz)
ret = datetime(time.year, time.month, time.day, time.hour,
time.minute, time.second)
return ret
3.在调用时使用now来调用当前的时间即可
其它的时间由自己运算得到就可以