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


PHP Date_Calc::dayOfYear方法代码示例

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


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

示例1: getDayOfYear

 /**
  * Returns the no of days (1-366) since 31st December of the previous year
  *
  * @return   int        an integer between 1 and 366
  * @access   public
  * @since    Method available since Release 1.5.0
  */
 function getDayOfYear()
 {
     return Date_Calc::dayOfYear($this->day, $this->month, $this->year);
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: round

 /**
  * Rounds the date according to the specified precision
  *
  * The precision parameter must be one of the following constants:
  *
  *  <code>DATE_PRECISION_YEAR</code>
  *  <code>DATE_PRECISION_MONTH</code>
  *  <code>DATE_PRECISION_DAY</code>
  *  <code>DATE_PRECISION_HOUR</code>
  *  <code>DATE_PRECISION_10MINUTES</code>
  *  <code>DATE_PRECISION_MINUTE</code>
  *  <code>DATE_PRECISION_10SECONDS</code>
  *  <code>DATE_PRECISION_SECOND</code>
  *
  * The precision can also be specified as an integral offset from
  * one of these constants, where the offset reflects a precision
  * of 10 to the power of the offset greater than the constant.
  * For example:
  *
  *  <code>DATE_PRECISION_YEAR - 1</code> rounds the date to the nearest 10
  *                                      years
  *  <code>DATE_PRECISION_YEAR - 3</code> rounds the date to the nearest 1000
  *                                      years
  *  <code>DATE_PRECISION_SECOND + 1</code> rounds the date to 1 decimal
  *                                        point of a second
  *  <code>DATE_PRECISION_SECOND + 1</code> rounds the date to 3 decimal
  *                                        points of a second
  *  <code>DATE_PRECISION_SECOND + 1</code> rounds the date to the nearest 10
  *                                        seconds (thus it is equivalent to
  *                                        DATE_PRECISION_10SECONDS)
  *
  * N.B. This function requires a time in UTC if both the precision is at
  * least DATE_PRECISION_SECOND and leap seconds are being counted, otherwise
  * any local time is acceptable.
  *
  * @param int   $pn_precision a 'DATE_PRECISION_*' constant
  * @param int   $pn_day       the day of the month
  * @param int   $pn_month     the month
  * @param int   $pn_year      the year
  * @param int   $pn_hour      the hour
  * @param int   $pn_minute    the minute
  * @param mixed $pn_second    the second as integer or float
  * @param bool  $pb_countleap whether to count leap seconds (defaults to
  *                             DATE_COUNT_LEAP_SECONDS)
  *
  * @return   array      array of year, month, day, hour, minute, second
  * @access   public
  * @static
  * @since    Method available since Release 1.5.0
  */
 function round($pn_precision, $pn_day, $pn_month, $pn_year, $pn_hour = 0, $pn_minute = 0, $pn_second = 0, $pb_countleap = DATE_COUNT_LEAP_SECONDS)
 {
     if ($pn_precision <= DATE_PRECISION_YEAR) {
         $hn_month = 0;
         $hn_day = 0;
         $hn_hour = 0;
         $hn_minute = 0;
         $hn_second = 0;
         if ($pn_precision < DATE_PRECISION_YEAR) {
             $hn_year = round($pn_year, $pn_precision - DATE_PRECISION_YEAR);
         } else {
             // Check part-year:
             //
             $hn_midyear = (Date_Calc::firstDayOfYear($pn_year + 1) - Date_Calc::firstDayOfYear($pn_year)) / 2;
             if (($hn_days = Date_Calc::dayOfYear($pn_day, $pn_month, $pn_year)) <= $hn_midyear - 1) {
                 $hn_year = $pn_year;
             } else {
                 if ($hn_days >= $hn_midyear) {
                     // Round up:
                     //
                     $hn_year = $pn_year + 1;
                 } else {
                     // Take time into account:
                     //
                     $hn_partday = Date_Calc::secondsPastMidnight($pn_hour, $pn_minute, $pn_second) / 86400;
                     if ($hn_partday >= $hn_midyear - $hn_days) {
                         // Round up:
                         //
                         $hn_year = $pn_year + 1;
                     } else {
                         $hn_year = $pn_year;
                     }
                 }
             }
         }
     } else {
         if ($pn_precision == DATE_PRECISION_MONTH) {
             $hn_year = $pn_year;
             $hn_day = 0;
             $hn_hour = 0;
             $hn_minute = 0;
             $hn_second = 0;
             $hn_firstofmonth = Date_Calc::firstDayOfMonth($pn_month, $pn_year);
             $hn_midmonth = (Date_Calc::lastDayOfMonth($pn_month, $pn_year) + 1 - $hn_firstofmonth) / 2;
             if (($hn_days = Date_Calc::dateToDays($pn_day, $pn_month, $pn_year) - $hn_firstofmonth) <= $hn_midmonth - 1) {
                 $hn_month = $pn_month;
             } else {
                 if ($hn_days >= $hn_midmonth) {
                     // Round up:
                     //
//.........这里部分代码省略.........
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:101,代码来源:Calc.php

示例3: compare

compare(2451871, Date_Calc::dateToDays(22, 11, 2000), 'dateToDays');
compare('20001122', Date_Calc::daysToDate(2451871), 'daysToDate');
compare('2000-47-3', Date_Calc::gregorianToISO('22', '11', '2000'), 'gregorianToISO str');
compare('2000-47-3', Date_Calc::gregorianToISO(22, 11, 2000), 'gregorianToISO');
compare(2451716.56767, Date_Calc::dateSeason('SUMMERSOLSTICE', 2000), 'dateSeason');
compare(date('Ymd'), Date_Calc::dateNow(), 'dateNow');
compare(date('Y'), Date_Calc::getYear(), 'getYear');
compare(date('m'), Date_Calc::getMonth(), 'getMonth');
compare(date('d'), Date_Calc::getDay(), 'getDay');
compare(327, Date_Calc::dayOfYear(22, 11, 2000), 'dayOfYear');
compare('November', Date_Calc::getMonthFullname(11), 'getMonthFullname');
compare('Nov', Date_Calc::getMonthAbbrname(11), 'getMonthAbbrname');
compare('Saturday', Date_Calc::getWeekdayFullname(1, 1, 2005), 'getWeekdayFullname');
compare('Sat', Date_Calc::getWeekdayAbbrname(1, 1, 2005), 'getWeekdayAbbrname');
compare(11, Date_Calc::getMonthFromFullName('November'), 'getMonthFromFullName');
compare(327, Date_Calc::dayOfYear('22', '11', '2000'), 'dayOfYear str');
compare('November', Date_Calc::getMonthFullname('11'), 'getMonthFullname str');
compare('Nov', Date_Calc::getMonthAbbrname('11'), 'getMonthAbbrname str');
compare('Saturday', Date_Calc::getWeekdayFullname('01', '01', '2005'), 'getWeekdayFullname str');
compare('Sat', Date_Calc::getWeekdayAbbrname('01', '01', '2005'), 'getWeekdayAbbrname str');
$exp = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
compare($exp, Date_Calc::getMonthNames(), 'getMonthNames');
$exp = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
compare($exp, Date_Calc::getWeekDays(), 'getWeekDays');
compare(3, Date_Calc::dayOfWeek(22, 11, 2000), 'dayOfWeek');
compare(47, Date_Calc::weekOfYear(22, 11, 2000), 'weekOfYear');
compare(4, Date_Calc::quarterOfYear(22, 11, 2000), 'quarterOfYear');
compare(3, Date_Calc::dayOfWeek('22', '11', '2000'), 'dayOfWeek str');
compare(47, Date_Calc::weekOfYear('22', '11', '2000'), 'weekOfYear str');
compare(4, Date_Calc::quarterOfYear('22', '11', '2000'), 'quarterOfYear str');
compare(28, Date_Calc::daysInMonth(2, 1900), 'daysInMonth 1');
开发者ID:MagnusA,项目名称:Date,代码行数:31,代码来源:calc.php


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