本文整理汇总了PHP中QDateTime::Difference方法的典型用法代码示例。如果您正苦于以下问题:PHP QDateTime::Difference方法的具体用法?PHP QDateTime::Difference怎么用?PHP QDateTime::Difference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::Difference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOperations2
public function testOperations2()
{
$obj1 = QDateTime::Now();
$obj2 = new QDateTime($obj1);
// exact same time
$obj1->Year = $obj1->Year + 1;
$obj1->AddDays(1);
$diff = $obj2->Difference($obj1);
$this->assertTrue($diff->IsNegative());
$this->assertEqual($diff->Years, -1);
}
示例2: __toStringStatusStyled
/**
* Returns the status (styled) of a Receipt based on it's ReceivedFlag
*
* @return string that says either Received or Pending
*/
public function __toStringStatusStyled()
{
if ($this->ReceivedFlag) {
$strToReturn = 'Received';
} elseif ($this->DueDate && $this->DueDate->IsEarlierThan(new QDateTime(QDateTime::Now))) {
$now = new QDateTime(QDateTime::Now);
$dtsDifference = $now->Difference($this->DueDate);
$strToReturn = sprintf('<strong style="color:#BC3500;">Pending</strong>', $dtsDifference->Days);
} else {
$strToReturn = '<strong style="color:#CC9933;">Pending</strong>';
}
return sprintf('%s', $strToReturn);
}
示例3: SetFromQDateTime
/**
* Sets current QDateTimeSpan to the difference between two QDateTime objects
*
* @param QDateTime $dttFrom
* @param QDateTime $dttTo
*/
public function SetFromQDateTime(QDateTime $dttFrom, QDateTime $dttTo)
{
$this->Add($dttFrom->Difference($dttTo));
}