>>> import datetime >>> datetime.datetime.now() datetime.datetime(2010, 1, 30, 11, 49, 0, 364016) >>> d = datetime.datetime.now() >>> d datetime.datetime(2010, 1, 30, 11, 49, 16, 339859) >>> str(d) '2010-01-30 11:49:16.339859' >>> d.strftime("%Y%m%d%H%M%S") '20100130114916' >>> d2 = datetime.datetime.strptime('20100201012030', '%Y%m%d%H%M%S') >>> d2 datetime.datetime(2010, 2, 1, 1, 20, 30) >>> str(d2) '2010-02-01 01:20:30' >>> dd = d2 - d >>> dd datetime.timedelta(1, 48673, 660141) >>> str(dd) '1 day, 13:31:13.660141' >>> dd.seconds 48673 >>> dd += datetime.timedelta(days=+1) >>> dd datetime.timedelta(2, 48673, 660141) >>> str(dd) '2 days, 13:31:13.660141'