Trace/src/TimestampTrait.php
private function formatDate($when = null)
    {
        if (is_string($when)) {
            return $when;
        } elseif (!$when) {
            list($usec, $sec) = explode(' ', microtime());
            $micro = sprintf("%06d", $usec * 1000000);
            $when = new \DateTime(date('Y-m-d H:i:s.' . $micro));
        } elseif (is_numeric($when)) {
            // Expect that this is a timestamp
            $micro = sprintf("%06d", ($when - floor($when)) * 1000000);
            $when = new \DateTime(date('Y-m-d H:i:s.'. $micro, (int) $when));
        }
        $when->setTimezone(new \DateTimeZone('UTC'));
        return $when->format('Y-m-d\TH:i:s.u000\Z');
    }
private function formatDate($when = null)
    {
        if (is_string($when)) {
            return $when;
        } elseif (!$when) {
            list($usec, $sec) = explode(' ', microtime());
            $micro = sprintf("%06d", $usec * 1000000);
            $when = new \DateTime(date('Y-m-d H:i:s.' . $micro));
        } elseif (is_numeric($when)) {
            // Expect that this is a timestamp
            $micro = sprintf("%06d", ($when - floor($when)) * 1000000);
            $when = new \DateTime(date('Y-m-d H:i:s.'. $micro, (int) $when));
        }
        $when->setTimezone(new \DateTimeZone('UTC'));
        return $when->format('Y-m-d\TH:i:s.u000\Z');
    }
private function formatDate ( $ when = null ) { if ( is_string ( $ when ) ) { return $ when ; } elseif ( ! $ when ) { list ( $ usec , $ sec ) = explode ( ' ' , microtime ( ) ) ; $ micro = sprintf ( "%06d" , $ usec * 1000000 ) ; $ when = new \ DateTime ( date ( 'Y-m-d H:i:s.' . $ micro ) ) ; } elseif ( is_numeric ( $ when ) ) { // Expect that this is a timestamp $ micro = sprintf ( "%06d" , ( $ when - floor ( $ when ) ) * 1000000 ) ; $ when = new \ DateTime ( date ( 'Y-m-d H:i:s.' . $ micro , ( int ) $ when ) ) ; } $ when -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; return $ when -> format ( 'Y-m-d\TH:i:s.u000\Z' ) ; }
Returns a "Zulu" formatted string representing the provided \DateTime.

@param  \DateTimeInterface|int|float|string $when [optional] The end time of this span.
**Defaults to** now. If provided as a string, it must be in "Zulu" format.
If provided as an int or float, it is expected to be a Unix timestamp.
@return string
Returns a Zulu formatted string representing the provided \ DateTime .