本文整理汇总了PHP中Time::Hour方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::Hour方法的具体用法?PHP Time::Hour怎么用?PHP Time::Hour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::Hour方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetTime
/**
* @param Time $time
* @param bool $isEndTime
* @return Date
*/
public function SetTime(Time $time, $isEndTime = false)
{
$date = Date::Create($this->Year(), $this->Month(), $this->Day(), $time->Hour(), $time->Minute(), $time->Second(), $this->Timezone());
if ($isEndTime) {
if ($time->Hour() == 0 && $time->Minute() == 0 && $time->Second() == 0) {
return $date->AddDays(1);
}
}
return $date;
}
示例2: Compare
/**
* Compares this time to the one passed in
* Returns:
* -1 if this time is less than the passed in time
* 0 if the times are equal
* 1 if this time is greater than the passed in time
* @param Time $time
* @param Date|null $comparisonDate date to be used for time comparison
* @return int comparison result
*/
public function Compare(Time $time, $comparisonDate = null)
{
if ($comparisonDate != null) {
$myDate = Date::Create($comparisonDate->Year(), $comparisonDate->Month(), $comparisonDate->Day(), $this->Hour(), $this->Minute(), $this->Second(), $this->Timezone());
$otherDate = Date::Create($comparisonDate->Year(), $comparisonDate->Month(), $comparisonDate->Day(), $time->Hour(), $time->Minute(), $time->Second(), $time->Timezone());
return $myDate->Compare($otherDate);
}
return $this->GetDate()->Compare($time->GetDate());
}
示例3: testCanCreateTimeInServerTimezone
public function testCanCreateTimeInServerTimezone()
{
$hour = 10;
$min = 22;
$sec = 21;
$time = new Time($hour, $min, $sec);
$this->assertEquals("{$hour}:{$min}:{$sec}", $time->ToString());
$this->assertEquals($hour, $time->Hour());
$this->assertEquals($min, $time->Minute());
$this->assertEquals($sec, $time->Second());
$time = new Time($hour, $min);
$this->assertEquals("{$hour}:{$min}:00", $time->ToString());
$this->assertEquals($hour, $time->Hour());
$this->assertEquals($min, $time->Minute());
$this->assertEquals(0, $time->Second());
}