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


PHP DateHelper::timeSince方法代码示例

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


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

示例1: testTimeSince

 public function testTimeSince()
 {
     Localization::changeLocale('en_US');
     $minutes = 60;
     $hours = $minutes * 60;
     $days = $hours * 24;
     // time is in the future
     $future = time() + 7;
     $this->assertEquals($this->object->formatDate($future, false), $this->object->timeSince($future));
     // time is now
     $this->assertEquals('0 seconds', $this->object->timeSince(time()));
     // time is in the past (less that one year)
     $this->assertEquals('7 seconds', $this->object->timeSince(time() - 7));
     $this->assertEquals('3 minutes', $this->object->timeSince(time() - (3 * $minutes + 13)));
     $this->assertEquals('3 minutes, 13 seconds', $this->object->timeSince(time() - (3 * $minutes + 13), true));
     $this->assertEquals('4 hours', $this->object->timeSince(time() - (4 * $hours + 2 * $minutes)));
     $this->assertEquals('4 hours, 1 minute', $this->object->timeSince(time() - (4 * $hours + 1 * $minutes), true));
     $this->assertEquals('1 day', $this->object->timeSince(time() - (1 * $days + 1 * $minutes)));
     $this->assertEquals('2 days, 2 hours', $this->object->timeSince(time() - (2 * $days + 2 * $hours), true));
     $this->assertEquals('145 days', $this->object->timeSince(time() - 145 * $days));
     // time is in the past (more that one year)
     $this->assertEquals($this->object->formatDate(time() - 367 * $days, false), $this->object->timeSince(time() - 367 * $days));
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:23,代码来源:DateHelperTest.php

示例2: testTimeSince

 public function testTimeSince()
 {
     Localization::changeLocale("en_US");
     $minutes = 60;
     $hours = $minutes * 60;
     $days = $hours * 24;
     // time is in the future
     $future = time() + 7;
     $this->assertEquals($this->object->formatDate($future), $this->object->timeSince($future));
     // time is now
     $this->assertEquals("0 seconds", $this->object->timeSince(time()));
     // time is in the past
     $this->assertEquals("7 seconds", $this->object->timeSince(time() - 7));
     $this->assertEquals("3 minutes", $this->object->timeSince(time() - (3 * $minutes + 13)));
     $this->assertEquals("3 minutes, 13 seconds", $this->object->timeSince(time() - (3 * $minutes + 13), 1));
     $this->assertEquals("4 hours", $this->object->timeSince(time() - (4 * $hours + 2 * $minutes)));
     $this->assertEquals("4 hours, 1 minute", $this->object->timeSince(time() - (4 * $hours + 1 * $minutes), 1));
     $this->assertEquals("1 day", $this->object->timeSince(time() - (1 * $days + 1 * $minutes)));
     $this->assertEquals("2 days, 2 hours", $this->object->timeSince(time() - (2 * $days + 2 * $hours), 1));
     $this->assertEquals('145 days', $this->object->timeSince(time() - 145 * $days));
     $this->assertEquals($this->object->formatDate(time() - 367 * $days), $this->object->timeSince(time() - 367 * $days));
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:22,代码来源:DateHelperTest.php


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