def parsehttpdate ( string_ ) : try : t = time . strptime ( string_ , "%a, %d %b %Y %H:%M:%S %Z" ) except ValueError : return None return datetime . datetime ( * t [ : 6 ] )
date time string python http
Parses an HTTP date into a datetime object .
def parsehttpdate(string_):
    """
    Parses an HTTP date into a datetime object.

        >>> parsehttpdate('Thu, 01 Jan 1970 01:01:01 GMT')
        datetime.datetime(1970, 1, 1, 1, 1, 1)
    """
    try:
        t = time.strptime(string_, "%a, %d %b %Y %H:%M:%S %Z")
    except ValueError:
        return None
    return datetime.datetime(*t[:6])