标签:
import datetime as DT
#convert character string: ‘20150212 10:12:11‘ to datetime type: pTime
pTime = DT.datetime.strptime(‘20150212 10:12:11‘, ‘%Y%m%d %H:%M:%S‘)
#calculate the number of days between two date:utcnow() and pTime
days = ( DT.datetime.utcnow()- pTime ).days
#day of the year
DOY = ( pTime- DT.datetime(pTime.year, 1, 1) ).days+1
#calculate the time after 1h
aftTime = pTime+ DT.timedelta(hours=1)
标签:
原文地址:http://www.cnblogs.com/liangxw/p/5226277.html