>>> from datetime import datetime
>>> text = '2012-09-20'
>>> y = datetime.strptime(text,'%Y-%m-%d')
>>> y
datetime.datetime(2012, 9, 20, 0, 0)
>>> z = datetime.now()
>>> diff = z - y
>>> diff
datetime.timedelta(1968, 57379, 588592)
>>> z
datetime.datetime(2018, 2, 9, 15, 56, 19, 588592)
>>> z
datetime.datetime(2018, 2, 9, 15, 56, 19, 588592)
>>> nice_z = datetime.strftime(z, '%A %B %d, %Y')
>>> nice_z
'Friday February 09, 2018'
>>> text = '2012-09-20'
>>> y = datetime.strptime(text,'%Y-%m-%d')
>>> y
datetime.datetime(2012, 9, 20, 0, 0)
>>> z = datetime.now()
>>> diff = z - y
>>> diff
datetime.timedelta(1968, 57379, 588592)
>>> z
datetime.datetime(2018, 2, 9, 15, 56, 19, 588592)
>>> z
datetime.datetime(2018, 2, 9, 15, 56, 19, 588592)
>>> nice_z = datetime.strftime(z, '%A %B %d, %Y')
>>> nice_z
'Friday February 09, 2018'
Comments
Post a Comment
https://gengwg.blogspot.com/