from datetime import datetime


def _get_date(element):
    """ This function extracts the date the image was taken from the image element
    and converts it to a datetime format.

    Args:
        element: A dict cuntianing all the image attributes.

    Returns:
        Date the image was taken in the format of datatime.
    """
    date_taken = element.get('datetaken')
    datetime_date_taken = datetime.strptime(date_taken, '%Y-%m-%d %H:%M:%S')
    return datetime_date_taken