LOhit wrote:
My question is, the date is in "Month day-of-the-month time" format in the log file (ex. "Nov 22 15:15:42") and the current date I get from "datetime" module is in ISO format. How do I convert the date in log file to ISO format(or any other format) and then compare with the current date/time.

>>> import datetime # or try `from datetime import datetime` and use `datetime.today()`

>>> datetime.datetime.today()
datetime.datetime(2009, 2, 19, 16, 34, 40, 358989)

>>> datetime.datetime.today().strftime("%d-%m-%Y")
'19-02-2009'

>>> today=datetime.datetime.today().strftime("%d-%m-%Y")
>>> today
'19-02-2009'

>>> today_dtobj=datetime.datetime.strptime(today, "%d-%m-%Y")
>>> today_dtobj
datetime.datetime(2009, 2, 19, 0, 0)

>>> type(today_dtobj)
<type 'datetime.datetime'>

--
With Regards,

Parthan "technofreak" (2FF01026)
http://technofreak.in

_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to