On Dec 21, 3:05 pm, MRAB <pyt...@mrabarnett.plus.com> wrote: > tekionwrote: > > Ben, > > I do not have python 2.6 install, my version of Python is 2.4. > > Because of my version of Python I believe I have to perform what you > > have suggested: > > > This should, ideally, consist of two separate operations: > > > * parse the string, using a specific format, to create a ‘datetime’ > > object > > > * create a string representation of the datetime using your > > preferred > > string format > > > So I guess I am stuck on parsing the string "24/Nov/2009:12:00:00 > > -0500" using regex and or string function to get the output to > > "2009-11-24 12:00:00". It looks like I may have to use regex to > > accomplish this and also re-map Nov to "11". Does any one have any > > idea that would take "24/Nov/2009:HH:MM:SS" and format it to > > "2009-11-24 HH:MM:SS"? Thanks > > If you don't have the 'datetime' module then you can use the 'time' > instead. Use time.strptime() to parse the string and time.strftime() to > create the new string.
Thanks. This is what I have: time.strftime("%Y-%m-%d %H:%M:%S", time.strptime("24/Nov/ 2009:12:00:00", "%d/%b/%Y:%H:%M:%S") and it seems to work. -- http://mail.python.org/mailman/listinfo/python-list