本文整理汇总了PHP中Timestamp::equals方法的典型用法代码示例。如果您正苦于以下问题:PHP Timestamp::equals方法的具体用法?PHP Timestamp::equals怎么用?PHP Timestamp::equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timestamp
的用法示例。
在下文中一共展示了Timestamp::equals方法的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());
}
示例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());
}