import pytz
import datetime
from dateutil.parser import parse
Get a UTC datetime object from isoformat string
-
dt = parse(result2JSON['jwtData']['TokenExpiry'])
-
dateTimeObjFromJSON = dt.astimezone(pytz.utc)
-
print(dateTimeObjFromJSON)
Output iso
-
self.lastRunDate.isoformat()
Time Addition
-
createPersonTime = datetime.now(pytz.timezone("UTC"))
-
updatePersonTime = createPersonTime + datetime.timedelta(seconds=int(12))
Flask field
-
'nextScheduledRun': fields.DateTime(dt_format=u'iso8601', description='Next scheudled run'),
Base App Set Test datetime
-
testTime = datetime.datetime.now(pytz.timezone("UTC"))
-
appObj.setTestingDateTime(testTime)
or constant
-
testTime = pytz.timezone('UTC').localize(datetime.datetime(2020,1,14,23,3,1,0))
-
appObj.setTestingDateTime(testTime)
Now calls to
-
self.appObj.getCurDateTime()
are set
Seconds between times
-
import datetime as dt
-
-
a = dt.datetime(2013,12,30,23,59,59)
-
b = dt.datetime(2013,12,31,23,59,59)
-
-
(b-a).total_seconds()
RJM Article Type
Quick Reference