Skip to content

Instantly share code, notes, and snippets.

@Chitrank-Dixit
Created December 29, 2013 04:42
Show Gist options
  • Save Chitrank-Dixit/8167522 to your computer and use it in GitHub Desktop.
Save Chitrank-Dixit/8167522 to your computer and use it in GitHub Desktop.
Converting a Date from dd/mm/yyyy format to yyyy/mm/dd format in python a simple script The date are in the file 'testdate.txt' in dd/mm/yyyy format and after conversion look at convDate list
# from dd/mm/yyyy to yyyy/mm/dd format of dates
f = open('testdate.txt')
i = f.read()
print i
date = i.split("\n")
print date
convDate = []
for adate in date:
if '/' in adate:
curDate = adate[1:-1].split('/')
yymmdd = curDate[2] + '/' + curDate[1] + '/' + curDate[0]
print yymmdd
convDate.append(yymmdd)
print convDate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment