Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to print only date and not include the time in datetime.datetime.strptime()

I have this code :

>>> import datetime
>>> l = '2011-12-02'
>>> t = datetime.datetime.strptime(l, '%Y-%m-%d')
>>> print t
2011-12-02 00:00:00

my question is, it is possible that only the 2011-12-02 will be printed?

like image 301
gadss Avatar asked Sep 10 '25 18:09

gadss


1 Answers

>>> t.strftime('%Y-%m-%d')
'2011-12-02'
like image 74
Dan D. Avatar answered Sep 12 '25 08:09

Dan D.