lengthOfTime() public static method

Time length to human readable format.
See also: timeAgoInWords()
public static lengthOfTime ( integer $seconds, string | null $format = null, array $options = [] ) : string
$seconds integer
$format string | null
$options array - boolean v: verbose - boolean zero: if false: 0 days 5 hours => 5 hours etc. - int: accuracy (how many sub-formats displayed?) //TODO
return string
示例#1
0
 /**
  * TimeTest::testLengthOfTime()
  *
  * @return void
  */
 public function testLengthOfTime()
 {
     //$this->out($this->_header(__FUNCTION__), true);
     $ret = $this->Time->lengthOfTime(60);
     //pr($ret);
     // FIX ME! Doesn't work!
     $ret = $this->Time->lengthOfTime(-60);
     //pr($ret);
     $ret = $this->Time->lengthOfTime(-121);
     //pr($ret);
     $this->assertEquals('6 ' . __d('tools', 'Minutes') . ', 40 ' . __d('tools', 'Seconds'), $this->Time->lengthOfTime(400));
     $res = $this->Time->lengthOfTime(400, 'i');
     //pr($res);
     $this->assertEquals('6 ' . __d('tools', 'Minutes'), $res);
     $res = $this->Time->lengthOfTime(6 * DAY);
     //pr($res);
     $this->assertEquals('6 ' . __d('tools', 'Days') . ', 0 ' . __d('tools', 'Hours'), $res);
 }