src/Phinx/Console/Command/Rollback.php
public function getTargetFromDate($date)
    {
        if (!preg_match('/^\d{4,14}$/', $date)) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        // what we need to append to the date according to the possible date string lengths
        $dateStrlenToAppend = [
            14 => '',
            12 => '00',
            10 => '0000',
            8 => '000000',
            6 => '01000000',
            4 => '0101000000',
        ];

        if (!isset($dateStrlenToAppend[strlen($date)])) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        $target = $date . $dateStrlenToAppend[strlen($date)];

        $dateTime = \DateTime::createFromFormat('YmdHis', $target);

        if ($dateTime === false) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        return $dateTime->format('YmdHis');
    }
public function getTargetFromDate($date)
    {
        if (!preg_match('/^\d{4,14}$/', $date)) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        // what we need to append to the date according to the possible date string lengths
        $dateStrlenToAppend = [
            14 => '',
            12 => '00',
            10 => '0000',
            8 => '000000',
            6 => '01000000',
            4 => '0101000000',
        ];

        if (!isset($dateStrlenToAppend[strlen($date)])) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        $target = $date . $dateStrlenToAppend[strlen($date)];

        $dateTime = \DateTime::createFromFormat('YmdHis', $target);

        if ($dateTime === false) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        return $dateTime->format('YmdHis');
    }
public function getTargetFromDate ( $ date ) { if ( ! preg_match ( '/^\d{4,14}$/' , $ date ) ) { throw new \ InvalidArgumentException ( 'Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].' ) ; } // what we need to append to the date according to the possible date string lengths $ dateStrlenToAppend = [ 14 => '' , 12 => '00' , 10 => '0000' , 8 => '000000' , 6 => '01000000' , 4 => '0101000000' , ] ; if ( ! isset ( $ dateStrlenToAppend [ strlen ( $ date ) ] ) ) { throw new \ InvalidArgumentException ( 'Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].' ) ; } $ target = $ date . $ dateStrlenToAppend [ strlen ( $ date ) ] ; $ dateTime = \ DateTime :: createFromFormat ( 'YmdHis' , $ target ) ; if ( $ dateTime === false ) { throw new \ InvalidArgumentException ( 'Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].' ) ; } return $ dateTime -> format ( 'YmdHis' ) ; }
Get Target from Date

@param string $date The date to convert to a target.
@return string The target
Get Target from Date