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


PHP Timestamp::toDate方法代码示例

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


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

示例1: testNonEpoch

 public function testNonEpoch()
 {
     $future = '4683-03-04';
     $after = new Timestamp($future);
     $this->assertEquals('04', $after->getDay());
     $this->assertEquals('03', $after->getMonth());
     $this->assertEquals('4683', $after->getYear());
     $past = '1234-04-03';
     $before = new Timestamp($past);
     $this->assertEquals('03', $before->getDay());
     $this->assertEquals('04', $before->getMonth());
     $this->assertEquals('1234', $before->getYear());
     $this->assertFalse($after->equals($before));
     $this->assertEquals($future, $after->toDate());
     $this->assertEquals($past, $before->toDate());
     $time = ' 00:00.00';
     $this->assertEquals($future . $time, $after->toDateTime());
     $this->assertEquals($past . $time, $before->toDateTime());
     $past = '1-04-03';
     $before = new Timestamp($past);
     $this->assertEquals('03', $before->getDay());
     $this->assertEquals('04', $before->getMonth());
     $this->assertEquals(substr(date('Y', time()), 0, 2) . '01', $before->getYear());
     $past = '14-01-02';
     $before = new Timestamp($past);
     $this->assertEquals('02', $before->getDay());
     $this->assertEquals('01', $before->getMonth());
     $this->assertEquals(substr(date('Y', time()), 0, 2) . '14', $before->getYear());
     $past = '113-01-02';
     $before = new Timestamp($past);
     $this->assertEquals('02', $before->getDay());
     $this->assertEquals('01', $before->getMonth());
     $this->assertEquals('0113', $before->getYear());
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:34,代码来源:TimestampTest.class.php

示例2: testNonEpoch

 public function testNonEpoch()
 {
     $future = '4683-03-04';
     $after = new Timestamp($future);
     $this->assertEquals($after->getDay(), '04');
     $this->assertEquals($after->getMonth(), '03');
     $this->assertEquals($after->getYear(), '4683');
     $past = '1234-04-03';
     $before = new Timestamp($past);
     $this->assertEquals($before->getDay(), '03');
     $this->assertEquals($before->getMonth(), '04');
     $this->assertEquals($before->getYear(), '1234');
     $this->assertFalse($after->equals($before));
     $this->assertEquals($future, $after->toDate());
     $this->assertEquals($past, $before->toDate());
     $time = ' 00:00.00';
     $this->assertEquals($future . $time, $after->toDateTime());
     $this->assertEquals($past . $time, $before->toDateTime());
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:19,代码来源:TimestampTest.class.php


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