📄 date.php
字号:
case 'z' : $output[$i] = $this->get(Zend_Date::TIMEZONE, $locale); break; // zone offset case 'ZZZZ' : $output[$i] = $this->get(Zend_Date::GMT_DIFF_SEP, $locale); break; case 'ZZZ' : case 'ZZ' : case 'Z' : $output[$i] = $this->get(Zend_Date::GMT_DIFF, $locale); break; default : $notset = true; break; } // fill variable tokens if ($notset == true) { if (($output[$i][0] !== "'") and (preg_match('/y+/', $output[$i]))) { $length = strlen($output[$i]); $output[$i] = $this->get(Zend_Date::YEAR, $locale); $output[$i] = str_pad($output[$i], $length, '0', STR_PAD_LEFT); } if (($output[$i][0] !== "'") and (preg_match('/Y+/', $output[$i]))) { $length = strlen($output[$i]); $output[$i] = $this->get(Zend_Date::YEAR_8601, $locale); $output[$i] = str_pad($output[$i], $length, '0', STR_PAD_LEFT); } if (($output[$i][0] !== "'") and (preg_match('/A+/', $output[$i]))) { $length = strlen($output[$i]); $seconds = $this->get(Zend_Date::TIMESTAMP, $locale); $month = $this->get(Zend_Date::MONTH_SHORT, $locale); $day = $this->get(Zend_Date::DAY_SHORT, $locale); $year = $this->get(Zend_Date::YEAR, $locale); $seconds -= $this->mktime(0, 0, 0, $month, $day, $year, false); $output[$i] = str_pad($seconds, $length, '0', STR_PAD_LEFT); } if ($output[$i][0] === "'") { $output[$i] = substr($output[$i], 1); } } $notset = false; } return implode('', $output); } /** * Returns a string representation of the date which is equal with the timestamp * * @return string */ public function __toString() { return $this->toString(null, $this->_Locale); } /** * Returns a integer representation of the object * But returns false when the given part is no value f.e. Month-Name * * @param string|integer|Zend_Date $part OPTIONAL Defines the date or datepart to return as integer * @return integer|false */ public function toValue($part = null) { $result = $this->get($part); if (is_numeric($result)) { return intval("$result"); } else { return false; } } /** * Returns an array representation of the object * * @return array */ public function toArray() { return array('day' => $this->get(Zend_Date::DAY_SHORT), 'month' => $this->get(Zend_Date::MONTH_SHORT), 'year' => $this->get(Zend_Date::YEAR), 'hour' => $this->get(Zend_Date::HOUR_SHORT), 'minute' => $this->get(Zend_Date::MINUTE_SHORT), 'second' => $this->get(Zend_Date::SECOND_SHORT), 'timezone' => $this->get(Zend_Date::TIMEZONE), 'timestamp' => $this->get(Zend_Date::TIMESTAMP), 'weekday' => $this->get(Zend_Date::WEEKDAY_DIGIT), 'dayofyear' => $this->get(Zend_Date::DAY_OF_YEAR), 'week' => $this->get(Zend_Date::WEEK), 'gmtsecs' => $this->get(Zend_Date::TIMEZONE_SECS)); } /** * Returns a representation of a date or datepart * This could be for example a localized monthname, the time without date, * the era or only the fractional seconds. There are about 50 different supported date parts. * For a complete list of supported datepart values look into the docu * * @param string $part OPTIONAL Part of the date to return, if null the timestamp is returned * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input * @return integer|string date or datepart */ public function get($part = null, $locale = null) { if ($locale === null) { $locale = $this->getLocale(); } if (Zend_Locale::isLocale($part)) { $locale = $part; $part = null; } if ($part === null) { $part = Zend_Date::TIMESTAMP; } if (!defined("self::".$part)) { return $this->toString($part, $locale); } switch($part) { // day formats case Zend_Date::DAY : return $this->date('d', $this->getUnixTimestamp(), false); break; case Zend_Date::WEEKDAY_SHORT : $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false)); $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday)); return substr($day, 0, 3); break; case Zend_Date::DAY_SHORT : return $this->date('j', $this->getUnixTimestamp(), false); break; case Zend_Date::WEEKDAY : $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false)); return Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday)); break; case Zend_Date::WEEKDAY_8601 : return $this->date('N', $this->getUnixTimestamp(), false); break; case Zend_Date::DAY_SUFFIX : return $this->date('S', $this->getUnixTimestamp(), false); break; case Zend_Date::WEEKDAY_DIGIT : return $this->date('w', $this->getUnixTimestamp(), false); break; case Zend_Date::DAY_OF_YEAR : return $this->date('z', $this->getUnixTimestamp(), false); break; case Zend_Date::WEEKDAY_NARROW : $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false)); $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday)); return substr($day, 0, 1); break; case Zend_Date::WEEKDAY_NAME : $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false)); return Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday)); break; // week formats case Zend_Date::WEEK : return $this->date('W', $this->getUnixTimestamp(), false); break; // month formats case Zend_Date::MONTH_NAME : $month = $this->date('n', $this->getUnixTimestamp(), false); return Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'wide', $month)); break; case Zend_Date::MONTH : return $this->date('m', $this->getUnixTimestamp(), false); break; case Zend_Date::MONTH_NAME_SHORT : $month = $this->date('n', $this->getUnixTimestamp(), false); return Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month)); break; case Zend_Date::MONTH_SHORT : return $this->date('n', $this->getUnixTimestamp(), false); break; case Zend_Date::MONTH_DAYS : return $this->date('t', $this->getUnixTimestamp(), false); break; case Zend_Date::MONTH_NAME_NARROW : $month = $this->date('n', $this->getUnixTimestamp(), false); $mon = Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month)); return substr($mon, 0, 1); break; // year formats case Zend_Date::LEAPYEAR : return $this->date('L', $this->getUnixTimestamp(), false); break; case Zend_Date::YEAR_8601 : return $this->date('o', $this->getUnixTimestamp(), false); break; case Zend_Date::YEAR : return $this->date('Y', $this->getUnixTimestamp(), false); break; case Zend_Date::YEAR_SHORT : return $this->date('y', $this->getUnixTimestamp(), false); break; case Zend_Date::YEAR_SHORT_8601 : $year = $this->date('o', $this->getUnixTimestamp(), false); return substr($year, -2); break; // time formats case Zend_Date::MERIDIEM : $am = $this->date('a', $this->getUnixTimestamp(), false); if ($am == 'am') { return Zend_Locale_Data::getContent($locale, 'am'); } return Zend_Locale_Data::getContent($locale, 'pm'); break; case Zend_Date::SWATCH : return $this->date('B', $this->getUnixTimestamp(), false); break; case Zend_Date::HOUR_SHORT_AM : return $this->date('g', $this->getUnixTimestamp(), false); break; case Zend_Date::HOUR_SHORT : return $this->date('G', $this->getUnixTimestamp(), false); break; case Zend_Date::HOUR_AM : return $this->date('h', $this->getUnixTimestamp(), false); break; case Zend_Date::HOUR : return $this->date('H', $this->getUnixTimestamp(), false); break; case Zend_Date::MINUTE : return $this->date('i', $this->getUnixTimestamp(), false); break; case Zend_Date::SECOND : return $this->date('s', $this->getUnixTimestamp(), false); break; case Zend_Date::MINUTE_SHORT : return $this->date('i', $this->getUnixTimestamp(), false); break; case Zend_Date::SECOND_SHORT : return $this->date('s', $this->getUnixTimestamp(), false); break; case Zend_Date::MILLISECOND : return $this->_Fractional; break; // timezone formats case Zend_Date::TIMEZONE_NAME : return $this->date('e', $this->getUnixTimestamp(), false); break; case Zend_Date::DAYLIGHT : return $this->date('I', $this->getUnixTimestamp(), false); break; case Zend_Date::GMT_DIFF : return $this->date('O', $this->getUnixTimestamp(), false); break; case Zend_Date::GMT_DIFF_SEP : return $this->date('P', $this->getUnixTimestamp(), false); break; case Zend_Date::TIMEZONE : return $this->date('T', $this->getUnixTimestamp(), false); break; case Zend_Date::TIMEZONE_SECS : return $this->date('Z', $this->getUnixTimestamp(), false); break; // date strings case Zend_Date::ISO_8601 : return $this->date('c', $this->getUnixTimestamp(), false); break; case Zend_Date::RFC_2822 : return $this->date('r', $this->getUnixTimestamp(), false); break; case Zend_Date::TIMESTAMP : return $this->getUnixTimestamp(); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -