src/Chippyash/Validation/Common/ISO8601/SplitDate.php
public function splitDate($value)
    {
        $parts = Match::on($this->laxTime)
            ->test(true, function () use ($value) {
                $parts = explode(' ', $value);
                //join back zone part if found
                if (count($parts) == 3) {
                    $parts[1] .= ' ' . $parts[2];
                    unset($parts[2]);
                }
                return $parts;
            })
            ->test(false, function () use ($value) {
                return explode('t', $value);
            })
            ->value();
        //guard
        if (count($parts) == 0 || count($parts) > 2 || (count($parts) == 1 && empty($parts[0]))) {
            return array(null, null, null, $this->timepartFound, $this->zonepartFound);
        }
        if (count($parts) == 1) {
            //we have a date only
            return array($parts[0], null, null, $this->timepartFound, $this->zonepartFound);
        }
        if (count($parts) == 2) {
            $this->timepartFound = true;
            //we have a date and something else
            list($time, $zone) = $this->splitTime($parts[1]);
            if (!is_null($zone)) {
                return array($parts[0], $time, $zone, $this->timepartFound, $this->zonepartFound);
            } elseif (!is_null($time)) {
                return array($parts[0], $time, null, $this->timepartFound, $this->zonepartFound);
            }

            return array($parts[0], null, null, $this->timepartFound, $this->zonepartFound);
        }

        return array($parts[0], null, null, $this->timepartFound, $this->zonepartFound);
    }
public function splitDate($value)
    {
        $parts = Match::on($this->laxTime)
            ->test(true, function () use ($value) {
                $parts = explode(' ', $value);
                //join back zone part if found
                if (count($parts) == 3) {
                    $parts[1] .= ' ' . $parts[2];
                    unset($parts[2]);
                }
                return $parts;
            })
            ->test(false, function () use ($value) {
                return explode('t', $value);
            })
            ->value();
        //guard
        if (count($parts) == 0 || count($parts) > 2 || (count($parts) == 1 && empty($parts[0]))) {
            return array(null, null, null, $this->timepartFound, $this->zonepartFound);
        }
        if (count($parts) == 1) {
            //we have a date only
            return array($parts[0], null, null, $this->timepartFound, $this->zonepartFound);
        }
        if (count($parts) == 2) {
            $this->timepartFound = true;
            //we have a date and something else
            list($time, $zone) = $this->splitTime($parts[1]);
            if (!is_null($zone)) {
                return array($parts[0], $time, $zone, $this->timepartFound, $this->zonepartFound);
            } elseif (!is_null($time)) {
                return array($parts[0], $time, null, $this->timepartFound, $this->zonepartFound);
            }

            return array($parts[0], null, null, $this->timepartFound, $this->zonepartFound);
        }

        return array($parts[0], null, null, $this->timepartFound, $this->zonepartFound);
    }
public function splitDate ( $ value ) { $ parts = Match :: on ( $ this -> laxTime ) -> test ( true , function ( ) use ( $ value ) { $ parts = explode ( ' ' , $ value ) ; //join back zone part if found if ( count ( $ parts ) == 3 ) { $ parts [ 1 ] .= ' ' . $ parts [ 2 ] ; unset ( $ parts [ 2 ] ) ; } return $ parts ; } ) -> test ( false , function ( ) use ( $ value ) { return explode ( 't' , $ value ) ; } ) -> value ( ) ; //guard if ( count ( $ parts ) == 0 || count ( $ parts ) > 2 || ( count ( $ parts ) == 1 && empty ( $ parts [ 0 ] ) ) ) { return array ( null , null , null , $ this -> timepartFound , $ this -> zonepartFound ) ; } if ( count ( $ parts ) == 1 ) { //we have a date only return array ( $ parts [ 0 ] , null , null , $ this -> timepartFound , $ this -> zonepartFound ) ; } if ( count ( $ parts ) == 2 ) { $ this -> timepartFound = true ; //we have a date and something else list ( $ time , $ zone ) = $ this -> splitTime ( $ parts [ 1 ] ) ; if ( ! is_null ( $ zone ) ) { return array ( $ parts [ 0 ] , $ time , $ zone , $ this -> timepartFound , $ this -> zonepartFound ) ; } elseif ( ! is_null ( $ time ) ) { return array ( $ parts [ 0 ] , $ time , null , $ this -> timepartFound , $ this -> zonepartFound ) ; } return array ( $ parts [ 0 ] , null , null , $ this -> timepartFound , $ this -> zonepartFound ) ; } return array ( $ parts [ 0 ] , null , null , $ this -> timepartFound , $ this -> zonepartFound ) ; }
Split date by its parts

@param  string $value ISO datetime string
@return array[date, time, zone, timePartFound]
Split date by its parts