本文整理汇总了PHP中CakeTime::niceFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeTime::niceFormat方法的具体用法?PHP CakeTime::niceFormat怎么用?PHP CakeTime::niceFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeTime
的用法示例。
在下文中一共展示了CakeTime::niceFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNice
/**
* testNice method
*
* @return void
*/
public function testNice()
{
$time = time() + 2 * DAY;
$this->assertEquals(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = time() - 2 * DAY;
$this->assertEquals(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = time();
$this->assertEquals(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = 0;
$this->assertEquals(date('D, M jS Y, H:i', time()), $this->Time->nice($time));
$time = null;
$this->assertEquals(date('D, M jS Y, H:i', time()), $this->Time->nice($time));
$time = time();
$this->assertEquals(date('D', $time), $this->Time->nice($time, null, '%a'));
$this->assertEquals(date('M d, Y', $time), $this->Time->nice($time, null, '%b %d, %Y'));
$this->Time->niceFormat = '%Y-%d-%m';
$this->assertEquals(date('Y-d-m', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m', $this->Time->niceFormat);
CakeTime::$niceFormat = '%Y-%d-%m %H:%M';
$this->assertEquals(date('Y-d-m H:i', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m %H:%M', $this->Time->niceFormat);
date_default_timezone_set('UTC');
$result = $this->Time->nice(null, 'America/New_York');
$expected = $this->Time->nice(time(), 'America/New_York');
$this->assertEquals(substr($expected, 0, -1), substr($result, 0, -1));
$this->_restoreSystemTimezone();
}
示例2: testNice
/**
* testNice method
*
* @return void
*/
public function testNice()
{
$time = time() + 2 * DAY;
$this->assertEquals(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = time() - 2 * DAY;
$this->assertEquals(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = time();
$this->assertEquals(date('D, M jS Y, H:i', $time), $this->Time->nice($time));
$time = 0;
$this->assertEquals(date('D, M jS Y, H:i', time()), $this->Time->nice($time));
$time = null;
$this->assertEquals(date('D, M jS Y, H:i', time()), $this->Time->nice($time));
$time = time();
$this->assertEquals(date('D', $time), $this->Time->nice($time, null, '%a'));
$this->assertEquals(date('M d, Y', $time), $this->Time->nice($time, null, '%b %d, %Y'));
$this->Time->niceFormat = '%Y-%d-%m';
$this->assertEquals(date('Y-d-m', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m', $this->Time->niceFormat);
CakeTime::$niceFormat = '%Y-%d-%m %H:%M:%S';
$this->assertEquals(date('Y-d-m H:i:s', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m %H:%M:%S', $this->Time->niceFormat);
}