from time import strptime from time import localtime from datetime import date from datetime import datetime out="20150827173103" time1=datetime(time.strptime(out,"%Y%m%d%H%M%S")) print(time1) #string converted into time format# time2=time.strftime("%Y%m%d%H%M%S") print(time2) #got local time in string format# time3=datetime(time.strptime(time2,"%Y%m%d%H%M%S") #local time in string is converted into time format# diff=time3-time1 print(diff)
previous=date(2015,8,27) current=date.today() difference=current - previous print(difference)
t1=datetime.strptime("20150827130100", "%Y%m%d%H%M%S") t2=datetime.today() tdiff=t2-t1 tdiff
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)