Python convert date string to datetime
Question: Im trying to convert a date string into Python but get errors -

String: `'1986-09-22T00:00:00'`

    
    
    dob_python = datetime.strptime('1986-09-22T00:00:00' , '%Y-%m-%d%Z%H-%M-%S').date()
    

Error:-

    
    
    ValueError: time data '1986-09-22T00:00:00' does not match format '%Y-%m-%d%Z%H-%M-%S'
    


Answer: `T` is not a timezone. It is _just_ a separator. Don't use `%Z` to try and
parse it, use a literal `T`. Your time separators must match as well; you need
to look for `:` colons, not dashes:

    
    
    dob_python = datetime.strptime('1986-09-22T00:00:00', '%Y-%m-%dT%H:%M:%S').date()
    #                                                              ^  ^  ^
    

Demo:

    
    
    >>> from datetime import datetime
    >>> datetime.strptime('1986-09-22T00:00:00', '%Y-%m-%dT%H:%M:%S').date()
    datetime.date(1986, 9, 22)
    

