How to calculate two time?

Jean-Paul Calderone exarkun at divmod.com
Wed Oct 8 10:06:35 EDT 2008


On Wed, 8 Oct 2008 06:49:10 -0700 (PDT), lookon <areyoulookon at gmail.com> wrote:
>I have two string like "2007-03-27T08:54:43+08:00 "
>how do I get the hours between these two time(string format)?

That's ISO 8601 datetime format.  You might use epsilon.extime:

    >>> from epsilon.extime import Time
    >>> Time.fromISO8601TimeAndDate("2008-10-08T14:05:16.029246+00:00") - Time.fromISO8601TimeAndDate("2007-03-27T08:54:43+08:00")
    datetime.timedelta(561, 47433, 29246)

Jean-Paul



More information about the Python-list mailing list