Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

strftime python multiple formats

from datetime import datetime

def try_parsing_date(text):
    for fmt in ('%Y-%m-%d', '%d.%m.%Y', '%d/%m/%Y'):
        try:
            return datetime.strptime(text, fmt)
        except ValueError:
            pass
    raise ValueError('no valid date format found')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #strftime #python #multiple #formats
ADD COMMENT
Topic
Name
7+5 =