strtotime?

L

Leif K-Brooks

Irmen said:
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.
 
P

Peter Hansen

Leif said:
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:

From http://www.lemburg.com/files/python/mxDateTime.html:
------------------------------
DateTimeFrom(*args,**kws)

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.
 
T

Torzec Nicolas

have a look at the parsedate() method in the RFC822 package.
It may help you if your date is in "Internet format"

"parsedate(StringDate)
Attempts to parse a date according to the rules in RFC 2822. however,
some mailers don't follow that format as specified, so parsedate() tries
to guess correctly in such cases. date is a string containing an RFC
2822 date, such as 'Mon, 20 Nov 1995 19:12:08 -0500'. If it succeeds in
parsing the date, parsedate() returns a 9-tuple that can be passed
directly to time.mktime(); otherwise None will be returned. Note that
fields 6, 7, and 8 of the result tuple are not usable."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top