def date2str(date, iso_format=True):
    """
    Converts date in format: %Y%m%d %H:%M:%s.

    :param netcdftime.datetime date: A datetime or phony datetime objects
    :param boolean iso_format: ISO format date if True
    :returns: The corresponding formatted string
    :rtype: *str*

    """
    if iso_format:
        return '{0:04d}-{1:02d}-{2:02d}T{3:02d}:{4:02d}:{5:02d}'.format(date
            .year, date.month, date.day, date.hour, date.minute, date.second)
    else:
        return '{0:04d}{1:02d}{2:02d}{3:02d}{4:02d}{5:02d}'.format(date.
            year, date.month, date.day, date.hour, date.minute, date.second)
