Skip to content

Instantly share code, notes, and snippets.

@neilkod
Created May 3, 2011 01:08
Show Gist options
  • Save neilkod/952652 to your computer and use it in GitHub Desktop.
Save neilkod/952652 to your computer and use it in GitHub Desktop.
please help me get this to run in python 2.4
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
>>>
@rnelson
Copy link

rnelson commented May 3, 2011

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%

@rnelson
Copy link

rnelson commented May 3, 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