當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Time::Second方法代碼示例

本文整理匯總了PHP中Time::Second方法的典型用法代碼示例。如果您正苦於以下問題:PHP Time::Second方法的具體用法?PHP Time::Second怎麽用?PHP Time::Second使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Time的用法示例。


在下文中一共展示了Time::Second方法的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;
 }
開發者ID:hugutux,項目名稱:booked,代碼行數:15,代碼來源:Date.php

示例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());
 }
開發者ID:hugutux,項目名稱:booked,代碼行數:19,代碼來源:Time.php

示例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());
 }
開發者ID:utn-frm-si,項目名稱:booked,代碼行數:16,代碼來源:DateTests.php


注:本文中的Time::Second方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。