Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime, dateutil.parser
- d = dateutil.parser.parse('2008-09-26T01:51:42.000Z')
- print d.strftime('%m/%d/%Y') #==> '09/26/2008'
- >>> import time
- >>> timestamp = "2008-09-26T01:51:42.000Z"
- >>> ts = time.strptime(timestamp[:19], "%Y-%m-%dT%H:%M:%S")
- >>> time.strftime("%m/%d/%Y", ts)
- '09/26/2008'
- def datechange(datestr):
- dateobj=datestr.split('-')
- y=dateobj[0]
- m=dateobj[1]
- d=dateobj[2]
- datestr=d +'-'+ m +'-'+y
- return datestr
Add Comment
Please, Sign In to add comment