Simple question about yyyy/mm/dd
skip at pobox.com
skip at pobox.com
Thu Mar 19 12:50:03 EDT 2009
>> Hi all, I need to receive in input a date represented by a string in
>> the form "yyyy/mm/dd" (or reversed), then I need to assure that the
>> date is = the current date and then split the dates in variables like
>> year, month, day. Is there some module to do this quickly?
The dateutil package has a parser module which works well here:
>>> import dateutil.parser, datetime
>>> dateutil.parser.parse("2008/03/31")
datetime.datetime(2008, 3, 31, 0, 0)
>>> dateutil.parser.parse("2008/03/31") > datetime.datetime.now()
False
--
Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/
More information about the Python-list
mailing list