>>> import time
>>> f=time.strptime("November 29, 2010", "%B %d, %Y")
>>> f[0]
2010
>>> f[1]
11
>>> f[2]
29
>>> g=time.strftime("%m/%d/%y",f)
>>> g
'11/29/10'
>>> h=time.strftime("%m/%d/%y",time.strptime("October 4, 2012", "%B %d, %Y"))
>>> h
'10/04/12'
>>> time.strftime("%m/%d/%y",time.strptime("May 3, 2011", "%B %d, %Y"))
'05/03/11'
>>>time.strftime("%B %d, %Y",time.strptime("23-Jun-14","%d-%b-%y"))
'June 23, 2014'
Mostly Linux & Python syntax notes and hyperlinks.
Tuesday, March 30, 2010
python: converting from written out date to numeric
Use the chart at the bottom of http://docs.python.org/library/datetime.html for the %B, %d, %m etc.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2010
(37)
-
▼
March
(12)
- python: converting from written out date to numeric
- py-sig Manchester NH: Goffstown Man with T-Shirt f...
- py-sig notes#3 how to teach intro to python
- py-sig Manchester NH 7:20 and on, random notes
- At py-sig Manchester NH 7pm
- Linux: uncompress tar.Z when your Linux doesn't ha...
- vi text wrap
- Linux: We've got python2.4, we need python2.6 now,...
- Linux: setting the system time & date
- Linux: diff -rq
- Linux: grep for tab character
- vi split screen
-
▼
March
(12)
No comments:
Post a Comment