當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Date::toValue方法代碼示例

本文整理匯總了PHP中Zend\Date\Date::toValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Date::toValue方法的具體用法?PHP Date::toValue怎麽用?PHP Date::toValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Date\Date的用法示例。


在下文中一共展示了Date::toValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testToValue

 /**
  * Test for toValue
  */
 public function testToValue()
 {
     $locale = new Locale('de_AT');
     $date = new Date(1234567890, null, $locale);
     $date->setTimezone(date_default_timezone_get());
     $this->assertSame(1234567890, $date->toValue());
     $this->assertSame(14, $date->toValue(Date::DAY));
     $date->setTimezone('UTC');
     $this->assertSame(13, $date->toValue(Date::DAY));
     $this->assertFalse($date->toValue(Date::WEEKDAY_SHORT));
     $this->assertSame(13, $date->toValue(Date::DAY_SHORT));
     $this->assertFalse($date->toValue(Date::WEEKDAY));
     $this->assertSame(5, $date->toValue(Date::WEEKDAY_8601));
     $this->assertFalse($date->toValue(Date::DAY_SUFFIX));
     $this->assertSame(5, $date->toValue(Date::WEEKDAY_DIGIT));
     $this->assertSame(43, $date->toValue(Date::DAY_OF_YEAR));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NARROW));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NAME));
     $this->assertSame(7, $date->toValue(Date::WEEK));
     $this->assertFalse($date->toValue(Date::MONTH_NAME));
     $this->assertSame(2, $date->toValue(Date::MONTH));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_SHORT));
     $this->assertSame(2, $date->toValue(Date::MONTH_SHORT));
     $this->assertSame(28, $date->toValue(Date::MONTH_DAYS));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_NARROW));
     $this->assertSame(0, $date->toValue(Date::LEAPYEAR));
     $this->assertSame(2009, $date->toValue(Date::YEAR_8601));
     $this->assertSame(2009, $date->toValue(Date::YEAR));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT_8601));
     $this->assertFalse($date->toValue(Date::MERIDIEM));
     $this->assertSame(21, $date->toValue(Date::SWATCH));
     $this->assertSame(11, $date->toValue(Date::HOUR_SHORT_AM));
     $this->assertSame(23, $date->toValue(Date::HOUR_SHORT));
     $this->assertSame(11, $date->toValue(Date::HOUR_AM));
     $this->assertSame(23, $date->toValue(Date::HOUR));
     $this->assertSame(31, $date->toValue(Date::MINUTE));
     $this->assertSame(30, $date->toValue(Date::SECOND));
     $this->assertSame(0, $date->toValue(Date::MILLISECOND));
     $this->assertSame(31, $date->toValue(Date::MINUTE_SHORT));
     $this->assertSame(30, $date->toValue(Date::SECOND_SHORT));
     $this->assertFalse($date->toValue(Date::TIMEZONE_NAME));
     $this->assertSame(0, $date->toValue(Date::DAYLIGHT));
     $this->assertSame(0, $date->toValue(Date::GMT_DIFF));
     $this->assertFalse($date->toValue(Date::GMT_DIFF_SEP));
     $this->assertFalse($date->toValue(Date::TIMEZONE));
     $this->assertSame(0, $date->toValue(Date::TIMEZONE_SECS));
     $this->assertFalse($date->toValue(Date::ISO_8601));
     $this->assertFalse($date->toValue(Date::RFC_2822));
     $this->assertSame(1234567890, $date->toValue(Date::TIMESTAMP));
     $this->assertFalse($date->toValue(Date::ERA));
     $this->assertFalse($date->toValue(Date::ERA_NAME));
     $this->assertFalse($date->toValue(Date::DATES));
     $this->assertFalse($date->toValue(Date::DATE_FULL));
     $this->assertFalse($date->toValue(Date::DATE_LONG));
     $this->assertFalse($date->toValue(Date::DATE_MEDIUM));
     $this->assertFalse($date->toValue(Date::DATE_SHORT));
     $this->assertFalse($date->toValue(Date::TIMES));
     $this->assertFalse($date->toValue(Date::TIME_FULL));
     $this->assertFalse($date->toValue(Date::TIME_LONG));
     $this->assertFalse($date->toValue(Date::TIME_MEDIUM));
     $this->assertFalse($date->toValue(Date::TIME_SHORT));
     $this->assertFalse($date->toValue(Date::DATETIME));
     $this->assertFalse($date->toValue(Date::DATETIME_FULL));
     $this->assertFalse($date->toValue(Date::DATETIME_LONG));
     $this->assertFalse($date->toValue(Date::DATETIME_MEDIUM));
     $this->assertFalse($date->toValue(Date::DATETIME_SHORT));
     $this->assertFalse($date->toValue(Date::ATOM));
     $this->assertFalse($date->toValue(Date::COOKIE));
     $this->assertFalse($date->toValue(Date::RFC_822));
     $this->assertFalse($date->toValue(Date::RFC_850));
     $this->assertFalse($date->toValue(Date::RFC_1036));
     $this->assertFalse($date->toValue(Date::RFC_1123));
     $this->assertFalse($date->toValue(Date::RFC_3339));
     $this->assertFalse($date->toValue(Date::RSS));
     $this->assertFalse($date->toValue(Date::W3C));
     $date->setTimezone('Indian/Maldives');
     $this->assertFalse($date->toValue(Date::WEEKDAY_SHORT));
     $this->assertSame(14, $date->toValue(Date::DAY_SHORT));
     $this->assertFalse($date->toValue(Date::WEEKDAY));
     $this->assertSame(6, $date->toValue(Date::WEEKDAY_8601));
     $this->assertFalse($date->toValue(Date::DAY_SUFFIX));
     $this->assertSame(6, $date->toValue(Date::WEEKDAY_DIGIT));
     $this->assertSame(44, $date->toValue(Date::DAY_OF_YEAR));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NARROW));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NAME));
     $this->assertSame(7, $date->toValue(Date::WEEK));
     $this->assertFalse($date->toValue(Date::MONTH_NAME));
     $this->assertSame(2, $date->toValue(Date::MONTH));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_SHORT));
     $this->assertSame(2, $date->toValue(Date::MONTH_SHORT));
     $this->assertSame(28, $date->toValue(Date::MONTH_DAYS));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_NARROW));
     $this->assertSame(0, $date->toValue(Date::LEAPYEAR));
     $this->assertSame(2009, $date->toValue(Date::YEAR_8601));
     $this->assertSame(2009, $date->toValue(Date::YEAR));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT));
//.........這裏部分代碼省略.........
開發者ID:rikaix,項目名稱:zf2,代碼行數:101,代碼來源:DateTest.php


注:本文中的Zend\Date\Date::toValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。