src/Time/DateTime.php
protected function evaluateDateString($string)
    {
        $seconds = 1;
        $matches = [];
        preg_match('/^([0-9]*)([s|M|h|d|m|y])$/', $string, $matches);

        switch ($matches[2]) {
            case 's':
                $seconds = $matches[1];
                break;
            case 'M':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 's');
                break;
            case 'h':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 'M');
                break;
            case 'd':
                $seconds = $this->evaluateDateString(24 * $matches[1] . 'h');
                break;
            case 'm':
                $seconds = $this->evaluateDateString(30 * $matches[1] . 'd');
                break;
            case 'y':
                $seconds = $this->evaluateDateString(12 * $matches[1] . 'm');
                break;
        }

        return $seconds;
    }
protected function evaluateDateString($string)
    {
        $seconds = 1;
        $matches = [];
        preg_match('/^([0-9]*)([s|M|h|d|m|y])$/', $string, $matches);

        switch ($matches[2]) {
            case 's':
                $seconds = $matches[1];
                break;
            case 'M':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 's');
                break;
            case 'h':
                $seconds = $this->evaluateDateString(60 * $matches[1] . 'M');
                break;
            case 'd':
                $seconds = $this->evaluateDateString(24 * $matches[1] . 'h');
                break;
            case 'm':
                $seconds = $this->evaluateDateString(30 * $matches[1] . 'd');
                break;
            case 'y':
                $seconds = $this->evaluateDateString(12 * $matches[1] . 'm');
                break;
        }

        return $seconds;
    }
protected function evaluateDateString ( $ string ) { $ seconds = 1 ; $ matches = [ ] ; preg_match ( '/^([0-9]*)([s|M|h|d|m|y])$/' , $ string , $ matches ) ; switch ( $ matches [ 2 ] ) { case 's' : $ seconds = $ matches [ 1 ] ; break ; case 'M' : $ seconds = $ this -> evaluateDateString ( 60 * $ matches [ 1 ] . 's' ) ; break ; case 'h' : $ seconds = $ this -> evaluateDateString ( 60 * $ matches [ 1 ] . 'M' ) ; break ; case 'd' : $ seconds = $ this -> evaluateDateString ( 24 * $ matches [ 1 ] . 'h' ) ; break ; case 'm' : $ seconds = $ this -> evaluateDateString ( 30 * $ matches [ 1 ] . 'd' ) ; break ; case 'y' : $ seconds = $ this -> evaluateDateString ( 12 * $ matches [ 1 ] . 'm' ) ; break ; } return $ seconds ; }
Convert string to seconds

@param string $string The string

@return int
Convert string to seconds