String to Date function?

Gerrit Holl gerrit at nl.linux.org
Wed May 28 10:42:11 EDT 2003


Arsenal schreef op woensdag 28 mei om 16:22:54 +0000:
> I want to convert a string of format like "Mon Nov 25 21:32:11 2002"
> to a date in Python. According the lib. ref, i tried strptime(string[,
> format]) . But python complained that the time module doesnt have this
> function. Any advice appreciated!

Can you give us the *exact* code you were using?

This should work:

$ python
Python 2.3b1+ (#12, May 25 2003, 11:55:29)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
  0 >>> import time
  1 >>> time.strptime("Mon Nov 25 21:32:11 2002", "%a %b %d %H:%M:%S %Y")
(2002, 11, 25, 21, 32, 11, 0, 329, -1)

yours,
Gerrit.

-- 
231. If it kill a slave of the owner, then he shall pay slave for slave
to the owner of the house. 
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list