y2k y2k - 1 year ago 127
Python Question

Convert date Python

I have

dates, i.e. today is

How do I convert this to
, in Python?

Answer Source

I suggest the following:

import datetime
date = datetime.datetime.strptime("111609", "%m%d%y")
print date.strftime("%m/%d/%Y")

This will convert 010199 to 01/01/1999 and 010109 to 01/01/2009.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download