Answers for "check if a string can be converted into date or not python"

0

check if a string can be converted into date or not python

from dateutil.parser import parse

def is_date(string, fuzzy=False):
    """
    Return whether the string can be interpreted as a date.

    :param string: str, string to check for date
    :param fuzzy: bool, ignore unknown tokens in string if True
    """
    try: 
        parse(string, fuzzy=fuzzy)
        return True

    except ValueError:
        return False
Posted by: Guest on May-12-2021

Code answers related to "check if a string can be converted into date or not python"

Python Answers by Framework

Browse Popular Code Answers by Language