def METHOD_NAME(self, my_date, date_format):
    # supporting both cases, as data['form']['from_date'] is string
    if isinstance(my_date, str):
        formatted_date = time.strftime(
            date_format, time.strptime(my_date, "%Y-%m-%d")
        )
    else:
        formatted_date = my_date.strftime(date_format)
    return formatted_date or ""