public function toISOUTC(string $precision = '') : string
    {
        switch ($precision) {
            case '':
                $minor = '';
                break;
            case 'milliseconds':
                $minor = '.' . $this->format('v');
                break;
            case 'microseconds':
                $minor = '.' . $this->format('u');
                break;
            default:
                throw new \InvalidArgumentException(
                    'Arg precision[' . $precision . '] isn\'t empty or value milliseconds|microseconds.'
                );
        }
        return substr(
                (clone $this)->setTimezone(new \DateTimeZone('UTC'))->format('c'),
                0,
                -6
            ) . $minor . 'Z';
    }
public function toISOUTC(string $precision = '') : string
    {
        switch ($precision) {
            case '':
                $minor = '';
                break;
            case 'milliseconds':
                $minor = '.' . $this->format('v');
                break;
            case 'microseconds':
                $minor = '.' . $this->format('u');
                break;
            default:
                throw new \InvalidArgumentException(
                    'Arg precision[' . $precision . '] isn\'t empty or value milliseconds|microseconds.'
                );
        }
        return substr(
                (clone $this)->setTimezone(new \DateTimeZone('UTC'))->format('c'),
                0,
                -6
            ) . $minor . 'Z';
    }
public function toISOUTC ( string $ precision = '' ) : string { switch ( $ precision ) { case '' : $ minor = '' ; break ; case 'milliseconds' : $ minor = '.' . $ this -> format ( 'v' ) ; break ; case 'microseconds' : $ minor = '.' . $ this -> format ( 'u' ) ; break ; default : throw new \ InvalidArgumentException ( 'Arg precision[' . $ precision . '] isn\'t empty or value milliseconds|microseconds.' ) ; } return substr ( ( clone $ this ) -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) -> format ( 'c' ) , 0 , - 6 ) . $ minor . 'Z' ; }
To ISO-8601 UTC, optionally with milli- or microseconds precision.

Formats:
YYYY-MM-DDTHH:ii:ssZ
YYYY-MM-DDTHH:ii:ss.mmmZ
YYYY-MM-DDTHH:ii:ss.mmmmmmZ

Like Javascript Date.toISOString(); when milliseconds precision.

@param string $precision
Values: (empty)|milliseconds|microseconds.
Default: empty; with neither milli- nor microseconds.

@return string

@throws \InvalidArgumentException
Arg precision not empty or milliseconds|microseconds.
To ISO - 8601 UTC optionally with milli - or microseconds precision .