Peter Hansen peter at
Fri Jan 23 01:10:40 CET 2004

Leif K-Brooks wrote:
> Irmen de Jong wrote:
> >> PHP has a very nice strtotime function (
> >> which converts a date/time in virtually any format into a timestamp.
> >> Does Python have a similar function?
> >
> > I guess you're looking for:  time.strptime
> Thanks, but no. PHP's strtotime() function magically guesses the format
> on its own, time.strptime() just uses a fixed format.

Perhaps the mx.DateTime package would help:


Constructs a DateTime instance from the arguments. 

This constructor can parse strings, handle numeric arguments and knows about 
the keywords year,month,day,hour,minute,second.  

It uses type inference to find out how to interpret the arguments and makes 
use of the Parser module. 


More information about the Python-list mailing list