Created
May 3, 2011 01:08
-
-
Save neilkod/952652 to your computer and use it in GitHub Desktop.
please help me get this to run in python 2.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) | |
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import datetime | |
>>> month_begin_date = '201104' | |
>>> friendly_date = datetime.datetime.strptime(month_begin_date,'%Y%m').strftime('%B, %Y') | |
>>> print friendly_date | |
April, 2011 | |
>>> |
(And, yes, they are separate installs)
minimus% python2.4 -V
Python 2.4.5
minimus% python2.5 -V
Python 2.5.5
minimus% python2.6 -V
Python 2.6.6
minimus% python2.7 -V
Python 2.7.1
minimus%
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
minimus% python2.4 friendly.py
April, 2011
minimus% python2.5 friendly.py
April, 2011
minimus% python2.6 friendly.py
April, 2011
minimus% python2.7 friendly.py
April, 2011
minimus% cat friendly.py
import datetime
import time
month_begin_date = '201104'
time_obj = time.strptime(month_begin_date, '%Y%m')
friendly_date = time.strftime('%B, %Y', time_obj)
print friendly_date
minimus%