src/Leevel/Database/Condition.php
protected function parseTime(string $field, $value, string $type)
    {
        $field = str_replace('`', '', $field);
        $table = $this->getTable();

        if (!preg_match('/\(.*\)/', $field)) {
            if (preg_match('/(.+)\.(.+)/', $field, $matches)) {
                $table = $matches[1];
                $field = $matches[2];
            }
        }

        // 支持类型
        switch ($type) {
            case 'day':
                $value = (int) $value;

                if ($value > 31) {
                    throw new InvalidArgumentException(
                        sprintf('Days can only be less than 31,but %s given.', $value)
                    );
                }

                $date = getdate();
                $value = mktime(0, 0, 0, $date['mon'], $value, $date['year']);

                break;
            case 'month':
                $value = (int) $value;

                if ($value > 12) {
                    throw new InvalidArgumentException(
                        sprintf('Months can only be less than 12,but %s given.', $value)
                    );
                }

                $date = getdate();
                $value = mktime(0, 0, 0, $value, 1, $date['year']);

                break;
            case 'year':
                $value = mktime(0, 0, 0, 1, 1, (int) $value);

                break;
            case 'date':
            default:
                $value = strtotime($value);

                if (false === $value) {
                    throw new InvalidArgumentException(
                        'Please enter a right time of strtotime.'
                    );
                }

                break;
        }

        return $value;
    }
protected function parseTime(string $field, $value, string $type)
    {
        $field = str_replace('`', '', $field);
        $table = $this->getTable();

        if (!preg_match('/\(.*\)/', $field)) {
            if (preg_match('/(.+)\.(.+)/', $field, $matches)) {
                $table = $matches[1];
                $field = $matches[2];
            }
        }

        // 支持类型
        switch ($type) {
            case 'day':
                $value = (int) $value;

                if ($value > 31) {
                    throw new InvalidArgumentException(
                        sprintf('Days can only be less than 31,but %s given.', $value)
                    );
                }

                $date = getdate();
                $value = mktime(0, 0, 0, $date['mon'], $value, $date['year']);

                break;
            case 'month':
                $value = (int) $value;

                if ($value > 12) {
                    throw new InvalidArgumentException(
                        sprintf('Months can only be less than 12,but %s given.', $value)
                    );
                }

                $date = getdate();
                $value = mktime(0, 0, 0, $value, 1, $date['year']);

                break;
            case 'year':
                $value = mktime(0, 0, 0, 1, 1, (int) $value);

                break;
            case 'date':
            default:
                $value = strtotime($value);

                if (false === $value) {
                    throw new InvalidArgumentException(
                        'Please enter a right time of strtotime.'
                    );
                }

                break;
        }

        return $value;
    }
解析时间信息.

@param string $field
@param mixed  $value
@param string $type

@return mixed