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


PHP CDate::convertTZ方法代碼示例

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


在下文中一共展示了CDate::convertTZ方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testConvertTZ

 public function testConvertTZ()
 {
     $myDate1 = new CDate('', 'US/Eastern');
     $this->assertEquals($myDate1, new CDate('', 'US/Eastern'));
     $myDate2 = new CDate('', 'CST');
     $myDate2->convertTZ('EST');
     //This tweaks the test data in case the +1 is across the day change.
     $tmpHour = $myDate1->hour + 1 >= 24 ? $myDate1->hour + 1 - 24 : $myDate1->hour + 1;
     $this->assertEquals($tmpHour, $myDate2->hour);
     $this->assertEquals($myDate1->minute, $myDate2->minute);
     $myDate2->convertTZ('PST');
     $tmpHour = $myDate1->hour - 2 < 0 ? $myDate1->hour - 2 + 24 : $myDate1->hour - 2;
     $this->assertEquals($tmpHour, $myDate2->hour);
 }
開發者ID:joly,項目名稱:web2project,代碼行數:14,代碼來源:date.test.php

示例2: compare

 /**
 * Overloaded compare method
 *
 * The convertTZ calls are time intensive calls.	 When a compare call is
 * made in a recussive loop the lag can be significant.
 */
 function compare($d1, $d2, $convertTZ = false)
 {
     if (!is_object($d1)) {
         $d1 = new CDate($d1);
     } else {
         if (!is_object($d2)) {
             $d2 = new CDate($d2);
         }
     }
     if ($convertTZ) {
         $d1->convertTZ(new Date_TimeZone('UTC'));
         $d2->convertTZ(new Date_TimeZone('UTC'));
     }
     $days1 = Date_Calc::dateToDays($d1->day, $d1->month, $d1->year);
     $days2 = Date_Calc::dateToDays($d2->day, $d2->month, $d2->year);
     $comp_value = 0;
     if ($days1 - $days2) {
         $comp_value = $days1 - $days2;
     } else {
         if ($d1->hour - $d2->hour) {
             $comp_value = dPsgn($d1->hour - $d2->hour);
         } else {
             if ($d1->minute - $d2->minute) {
                 $comp_value = dPsgn($d1->minute - $d2->minute);
             } else {
                 if ($d1->second - $d2->second) {
                     $comp_value = dPsgn($d1->second - $d2->second);
                 }
             }
         }
     }
     return dPsgn($comp_value);
 }
開發者ID:hoodoogurus,項目名稱:dotprojecteap,代碼行數:39,代碼來源:date.class.php


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