public function convertToUnixTimestamp($dateTime)
    {
        // ignore fractional second
        if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:|\.\d+)(Z|[+-]\d{2}:\d{2})$/', $dateTime, $matches)) {
            $timestamp = gmmktime(
                $matches[4], $matches[5], $matches[6], // hours, minutes, seconds
                $matches[2], $matches[3], $matches[1]  // month, day, year
            );

            // local offset (timezone)
            if ($matches[7] !== 'Z') {
                preg_match('/^([+-])(\d{2}):(\d{2})$/', $matches[7], $matches);

                $offset = ($matches[1] === '-' ? -1 : 1) * ($matches[2] * 60 + $matches[3]) * 60;
                $timestamp -= $offset;
            }
        }

        return $timestamp;
    }
public function convertToUnixTimestamp($dateTime)
    {
        // ignore fractional second
        if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:|\.\d+)(Z|[+-]\d{2}:\d{2})$/', $dateTime, $matches)) {
            $timestamp = gmmktime(
                $matches[4], $matches[5], $matches[6], // hours, minutes, seconds
                $matches[2], $matches[3], $matches[1]  // month, day, year
            );

            // local offset (timezone)
            if ($matches[7] !== 'Z') {
                preg_match('/^([+-])(\d{2}):(\d{2})$/', $matches[7], $matches);

                $offset = ($matches[1] === '-' ? -1 : 1) * ($matches[2] * 60 + $matches[3]) * 60;
                $timestamp -= $offset;
            }
        }

        return $timestamp;
    }
public function convertToUnixTimestamp ( $ dateTime ) { // ignore fractional second if ( preg_match ( '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:|\.\d+)(Z|[+-]\d{2}:\d{2})$/' , $ dateTime , $ matches ) ) { $ timestamp = gmmktime ( $ matches [ 4 ] , $ matches [ 5 ] , $ matches [ 6 ] , // hours, minutes, seconds $ matches [ 2 ] , $ matches [ 3 ] , $ matches [ 1 ] // month, day, year ) ; // local offset (timezone) if ( $ matches [ 7 ] !== 'Z' ) { preg_match ( '/^([+-])(\d{2}):(\d{2})$/' , $ matches [ 7 ] , $ matches ) ; $ offset = ( $ matches [ 1 ] === '-' ? - 1 : 1 ) * ( $ matches [ 2 ] * 60 + $ matches [ 3 ] ) * 60 ; $ timestamp -= $ offset ; } } return $ timestamp ; }
Convert RFC 3339 timestamp string to Unix timestamp

@param string $dateTime

@return integer
Convert RFC 3339 timestamp string to Unix timestamp