def datetime_to_utc_datetime_iso8601(datetime, day_granularity=False):
    """ Convert a datetime into its iso8601 UTC date.

        Parameters:
            datetime: Datetime to convert.
            day_granularity: Apply the day granularity

        Returns:
            Converted date (string).

    """
    datetime = datetime.replace(microsecond=0)
    result = datetime.isoformat() + 'Z'
    if day_granularity:
        result = result[:-10]
    return result
