当前位置: 首页>>代码示例>>PHP>>正文


PHP date::set_year方法代码示例

本文整理汇总了PHP中date::set_year方法的典型用法代码示例。如果您正苦于以下问题:PHP date::set_year方法的具体用法?PHP date::set_year怎么用?PHP date::set_year使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在date的用法示例。


在下文中一共展示了date::set_year方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function get_week_of_year()
 {
     $day = $this->day;
     $month = $this->month;
     $year = $this->year;
     $mnth = array(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334);
     $y_isleap = $this->is_leap_year();
     $d = new date($this);
     $d->set_year($this->year - 1);
     $y_1_isleap = $d->is_leap_year();
     $day_of_year_number = $day + $mnth[$month - 1];
     if ($y_isleap && $month > 2) {
         $day_of_year_number++;
     }
     // find Jan 1 weekday (monday = 1, sunday = 7)
     $yy = ($year - 1) % 100;
     $c = $year - 1 - $yy;
     $g = $yy + intval($yy / 4);
     $jan1_weekday = 1 + intval(($c / 100 % 4 * 5 + $g) % 7);
     // weekday for year-month-day
     $h = $day_of_year_number + ($jan1_weekday - 1);
     $weekday = 1 + intval(($h - 1) % 7);
     // find if Y M D falls in YearNumber Y-1, WeekNumber 52 or
     if ($day_of_year_number <= 8 - $jan1_weekday && $jan1_weekday > 4) {
         $yearnumber = $year - 1;
         if ($jan1_weekday == 5 || $jan1_weekday == 6 && $y_1_isleap) {
             $weeknumber = 53;
         } else {
             $weeknumber = 52;
         }
     } else {
         $yearnumber = $year;
     }
     // find if Y M D falls in YearNumber Y+1, WeekNumber 1
     if ($yearnumber == $year) {
         if ($y_isleap) {
             $i = 366;
         } else {
             $i = 365;
         }
         if ($i - $day_of_year_number < 4 - $weekday) {
             $yearnumber++;
             $weeknumber = 1;
         }
     }
     // find if Y M D falls in YearNumber Y, WeekNumber 1 through 53
     if ($yearnumber == $year) {
         $j = $day_of_year_number + (7 - $weekday) + ($jan1_weekday - 1);
         $weeknumber = intval($j / 7);
         // kludge!!! - JMC
         if ($jan1_weekday > 4) {
             $weeknumber--;
         }
     }
     return $weeknumber;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:56,代码来源:date.class.php


注:本文中的date::set_year方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。