Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Representing date format for three letter month in Python

How do I represent a 3 letter month date format in python such as the following:

Jan 16, 2012

I know for January 16, 2012 the format is %B %d,%Y. Any ideas?

like image 525
user8929822 Avatar asked Nov 29 '17 16:11

user8929822


People also ask

How do I set date format in Python?

Use datetime. strftime(format) to convert a datetime object into a string as per the corresponding format . The format codes are standard directives for mentioning in which format you want to represent datetime. For example, the %d-%m-%Y %H:%M:%S codes convert date to dd-mm-yyyy hh:mm:ss format.


1 Answers

There's the three letter month format %b:

In [37]: datetime.strptime('Jan 16, 2012', '%b %d, %Y')
Out[37]: datetime.datetime(2012, 1, 16, 0, 0)
like image 151
Moses Koledoye Avatar answered Oct 25 '22 02:10

Moses Koledoye