日期补全.

@param string|int $date 日期
@param string     $type 类型

@return string
327031
private function _datePad($date, $type = 'year')
    {
        $padLength = $type == 'year' ? 4 : 2;
        $newDate = str_pad($date, $padLength, '0', STR_PAD_LEFT);

        return $newDate;
    }
196676
public static function dateAddDay($date, $day)
    {
        $daystr = "+$day day";
        $dateday = date("Y-m-d", strtotime($daystr, strtotime($date)));
        return $dateday;
    }
85996
public static CharSequence getJSDate(Date date)
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);

		return getJSDate(calendar);
	}
593443
protected function _date($date = null) {
		if ($date === null || !$date instanceof \DateTimeInterface) {
			return '';
		}
		$datePieces = [];
		$datePieces[] = $date->format('Y');
		// JavaScript uses 0-indexed months, so we need to subtract 1 month from PHP's output
		$datePieces[] = (int)($date->format('m')) - 1;
		$datePieces[] = (int)$date->format('d');
		$datePieces[] = (int)$date->format('H');
		$datePieces[] = (int)$date->format('i');
		$datePieces[] = (int)$date->format('s');

		return 'new Date(' . implode(', ', $datePieces) . ')';
	}
1036568
protected function _date($date = null) {
		$timeAgoInWords = $date ? $this->Time->timeAgoInWords($date, array('format' => Configure::read('Task.dateFormat'))) : $this->_none();
		return $this->_isCli ? $timeAgoInWords : $this->Html->tag('span', $timeAgoInWords, array('title' => $date instanceof DateTime ? $date->format(Configure::read('Task.dateFormat')) : $date));
	}
1210238
public function serializeDateTime(SerializationVisitorInterface $visitor, \DateTime $date, array $type, SerializationContext $context)
    {
        return $this->serializeDateTimeInterface($visitor, $date, $type, $context);
    }
1025564
public static function formatDate($date, $format = 'Y-m-d')
    {
        if (!$date) {
            return null;
        }
        $date = new DateTime($date);
        return $date->format($format);
    }
551917
public function dateFormat($date, string $format = 'M d Y'): string
    {
        if ($date instanceof DateTime) {
            return $date->format($format);
        } elseif (is_int($date)) {
            return date($format, $date);
        }

        return date($format, strtotime($date));
    }
635335
private static Calendar getCalendar(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }
683556
protected static function formatDate($date)
    {
        $d = \DateTime::createFromFormat('Y-m-d', $date);
        if (!$d) {
            $d = \DateTime::createFromFormat('Y-m-d H:i:s', $date);
        }
        return ($d ? $d->format('d/m/Y') : $date);
    }
545502
public function formatDate($date)
    {
        // Get format
        $format = 'date_format';
        if ($this->get('time') === 'yes') {
            $format = 'datetime_format';
        }
        return DateTimeObj::format($date, DateTimeObj::getSetting($format));
    }
420030
public static function is($date)
    {
        if (is_bool($date) || empty($date) xor ($date === 0 || $date === '0')) {
            return false;
        }
        $date = static::isTimestamp($date) ? '@' . (string)$date : $date;
        return (bool)date_create($date);
    }
156415
public function matchDate($date)
    {
        return $this->matchPart(
            $date,
        $this->formatRegex[$this->format][self::STRDATE]
        );
    }
738162
public static function dateSQLToForm($date)
    {
        //if (!empty($date) && $date != "0000-00-00" && $date != "0000-00-00 00:00:00"){
        if ($this->isDateSQL($date)) {
            $arr = explode('-', $date);
            $thn = (int)$arr[0];
            $bln = (int)$arr[1];
            $tgl = (int)$arr[2];

            if ($thn > 2000 AND $bln <= 12 AND $bln >= 1 AND $tgl <= 31 AND $tgl >= 1) {
                if ($tgl < 10) $tgl = '0' . $tgl;
                if ($bln < 10) $bln = '0' . $bln;
                if ($thn < 10) $thn = '0' . $thn;

                return $tgl . '/' . $bln . '/' . $thn;
            }
        }

        return '';
    }
717374
public function date($date, $format = null)
    {
        if ($this->isEmptyDate($date)) {
            return '';
        }

        $isLocalizerFormat = in_array($format, [Localizer::SHORT, Localizer::LONG, Localizer::VERBOSE]);

        if ($format && !$isLocalizerFormat) {
            return $this->toDateTime($date)->format($format);
        }

        if (!$this->localizer) {
            return $this->toDateTime($date)->format('Y-m-d');
        }

        return $this->localizer->date($date, $format ?: Localizer::SHORT);
    }
185844
public function display($type = self::DISPLAY_SHORT) : string
    {
        return Calendar::formatDate($this->toMutable(), $type);
    }
867868
function formatDateType( $fmt, $date = false )
    {
        if ( $date === false )
        {
            $date = time();
        }
        else if ( empty( $date ) )
        {
            $date = 0;
        }

        $text = date( eZLocale::transformToPHPFormat( $fmt, $this->DatePHPArray ), $date );
        return str_replace( array( '%D', '%l', '%M', '%F' ),
                            array( $this->shortDayName( date( 'w', $date ) ),
                                   $this->longDayName( date( 'w', $date ) ),
                                   $this->shortMonthName( date( 'n', $date ) ),
                                   $this->longMonthName( date( 'n', $date ) ) ),
                            $text );
    }