import datetime as DT #convert character string: ‘20150212 10:12:11‘ to datetime type: pTimepTime = DT.datetime.strptime(‘20150212 10:12:11‘, ‘%Y%m%d %H:%M:%S‘) #calculate the number of days between two date:utcnow() and pTimedays = ( DT.datetime.utcnow()- pTime ).days #day of the yearDOY = ( pTime- DT.datetime(pTime.year, 1, 1) ).days+1
#calculate the time after 1haftTime = pTime+ DT.timedelta(hours=1)
时间: 2024-10-14 13:49:20