当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::getTimestamp方法代码示例

本文整理汇总了PHP中Zend\Date\Date::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::getTimestamp方法的具体用法?PHP Date::getTimestamp怎么用?PHP Date::getTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Date\Date的用法示例。


在下文中一共展示了Date::getTimestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUsePhpNFormat

 /**
  * @ZF-7913
  */
 public function testUsePhpNFormat()
 {
     Date::setOptions(array('format_type' => 'php'));
     date_default_timezone_set('GMT');
     $date = new Date(mktime(20, 10, 0, 00, 20, 2009));
     $this->assertSame(gmdate('w', $date->getTimestamp()), $date->toString('w'));
     $this->assertSame(gmdate('d', $date->getTimestamp()), $date->toString('d'));
     $this->assertSame(gmdate('D', $date->getTimestamp()), $date->toString('D', 'en'));
     $this->assertSame(gmdate('j', $date->getTimestamp()), $date->toString('j'));
     $this->assertSame(gmdate('l', $date->getTimestamp()), $date->toString('l', 'en'));
     $this->assertSame(gmdate('N', $date->getTimestamp()), $date->toString('N'));
     $this->assertSame(gmdate('S', $date->getTimestamp()), $date->toString('S'));
     $this->assertSame(gmdate('z', $date->getTimestamp()), $date->toString('z'));
     $this->assertSame(gmdate('W', $date->getTimestamp()), $date->toString('W'));
     $this->assertSame(gmdate('F', $date->getTimestamp()), $date->toString('F', 'en'));
     $this->assertSame(gmdate('m', $date->getTimestamp()), $date->toString('m'));
     $this->assertSame(gmdate('M', $date->getTimestamp()), $date->toString('M', 'en'));
     $this->assertSame(gmdate('n', $date->getTimestamp()), $date->toString('n'));
     $this->assertSame(gmdate('t', $date->getTimestamp()), $date->toString('t'));
     $this->assertSame(gmdate('L', $date->getTimestamp()), $date->toString('L'));
     $this->assertSame(gmdate('o', $date->getTimestamp()), $date->toString('o'));
     $this->assertSame(gmdate('Y', $date->getTimestamp()), $date->toString('Y'));
     $this->assertSame(gmdate('y', $date->getTimestamp()), $date->toString('y'));
     $this->assertSame(gmdate('a', $date->getTimestamp()), strtolower($date->toString('a', 'en')));
     $this->assertSame(gmdate('A', $date->getTimestamp()), strtoupper($date->toString('A', 'en')));
     $this->assertSame(gmdate('B', $date->getTimestamp()), $date->toString('B'));
     $this->assertSame(gmdate('g', $date->getTimestamp()), $date->toString('g'));
     $this->assertSame(gmdate('G', $date->getTimestamp()), $date->toString('G'));
     $this->assertSame(gmdate('h', $date->getTimestamp()), $date->toString('h'));
     $this->assertSame(gmdate('H', $date->getTimestamp()), $date->toString('H'));
     $this->assertSame(gmdate('i', $date->getTimestamp()), $date->toString('i'));
     $this->assertSame(gmdate('s', $date->getTimestamp()), $date->toString('s'));
     $this->assertSame(date('e', $date->getTimestamp()), $date->toString('e'));
     $this->assertSame(gmdate('I', $date->getTimestamp()), $date->toString('I'));
     $this->assertSame(gmdate('O', $date->getTimestamp()), $date->toString('O'));
     $this->assertSame(gmdate('P', $date->getTimestamp()), $date->toString('P'));
     $this->assertSame(gmdate('T', $date->getTimestamp()), $date->toString('T'));
     $this->assertSame(gmdate('Z', $date->getTimestamp()), $date->toString('Z'));
     $this->assertSame(gmdate('c', $date->getTimestamp()), $date->toString('c'));
     $this->assertSame(gmdate('r', $date->getTimestamp()), $date->toString('r'));
     $this->assertSame(gmdate('U', $date->getTimestamp()), $date->toString('U'));
     date_default_timezone_set('Indian/Maldives');
     $date = new Date(mktime(20, 10, 0, 00, 20, 2009));
     $this->assertSame(date('w', $date->getTimestamp()), $date->toString('w'));
     $this->assertSame(date('d', $date->getTimestamp()), $date->toString('d'));
     $this->assertSame(date('D', $date->getTimestamp()), $date->toString('D', 'en'));
     $this->assertSame(date('j', $date->getTimestamp()), $date->toString('j'));
     $this->assertSame(date('l', $date->getTimestamp()), $date->toString('l', 'en'));
     $this->assertSame(date('N', $date->getTimestamp()), $date->toString('N'));
     $this->assertSame(date('S', $date->getTimestamp()), $date->toString('S'));
     $this->assertSame(date('z', $date->getTimestamp()), $date->toString('z'));
     $this->assertSame(date('W', $date->getTimestamp()), $date->toString('W'));
     $this->assertSame(date('F', $date->getTimestamp()), $date->toString('F', 'en'));
     $this->assertSame(date('m', $date->getTimestamp()), $date->toString('m'));
     $this->assertSame(date('M', $date->getTimestamp()), $date->toString('M', 'en'));
     $this->assertSame(date('n', $date->getTimestamp()), $date->toString('n'));
     $this->assertSame(date('t', $date->getTimestamp()), $date->toString('t'));
     $this->assertSame(date('L', $date->getTimestamp()), $date->toString('L'));
     $this->assertSame(date('o', $date->getTimestamp()), $date->toString('o'));
     $this->assertSame(date('Y', $date->getTimestamp()), $date->toString('Y'));
     $this->assertSame(date('y', $date->getTimestamp()), $date->toString('y'));
     $this->assertSame(date('a', $date->getTimestamp()), strtolower($date->toString('a', 'en')));
     $this->assertSame(date('A', $date->getTimestamp()), strtoupper($date->toString('A', 'en')));
     $this->assertSame(date('B', $date->getTimestamp()), $date->toString('B'));
     $this->assertSame(date('g', $date->getTimestamp()), $date->toString('g'));
     $this->assertSame(date('G', $date->getTimestamp()), $date->toString('G'));
     $this->assertSame(date('h', $date->getTimestamp()), $date->toString('h'));
     $this->assertSame(date('H', $date->getTimestamp()), $date->toString('H'));
     $this->assertSame(date('i', $date->getTimestamp()), $date->toString('i'));
     $this->assertSame(date('s', $date->getTimestamp()), $date->toString('s'));
     $this->assertSame(date('e', $date->getTimestamp()), $date->toString('e'));
     $this->assertSame(date('I', $date->getTimestamp()), $date->toString('I'));
     $this->assertSame(date('O', $date->getTimestamp()), $date->toString('O'));
     $this->assertSame(date('P', $date->getTimestamp()), $date->toString('P'));
     $this->assertSame(date('T', $date->getTimestamp()), $date->toString('T'));
     $this->assertSame(date('Z', $date->getTimestamp()), $date->toString('Z'));
     $this->assertSame(date('c', $date->getTimestamp()), $date->toString('c'));
     $this->assertSame(date('r', $date->getTimestamp()), $date->toString('r'));
     $this->assertSame(date('U', $date->getTimestamp()), $date->toString('U'));
     Date::setOptions(array('format_type' => 'iso'));
 }
开发者ID:rikaix,项目名称:zf2,代码行数:84,代码来源:DateTest.php


注:本文中的Zend\Date\Date::getTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。