datetime question

Chris Rebert clp2 at rebertia.com
Fri Mar 6 10:29:18 EST 2009


On Fri, Mar 6, 2009 at 7:24 AM,  <jyoung79 at kc.rr.com> wrote:
> Just curious if this is the best way to get the first 3 letters of the current month?
>
>>>> import datetime
>>>>
>>>> d = datetime.date.today()
>>>> m = d.strftime("%B")[:3].upper()
>>>> m
> 'MAR'

I believe you want the lowercase version, "%b" (Locale’s abbreviated
month name):

>>> import datetime
>>> datetime.date.today().strftime("%b")
'Mar'

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list