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


PHP DateTimeValue::beginningOfDay方法代码示例

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


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

示例1: getRecentActivity

 /**
  * Get recent activity for a repository
  *
  * @param Repository $repository
  * @param int $from_days_before
  * @return array
  */
 function getRecentActivity($repository, $from_days_before = 15)
 {
     $from = new DateTimeValue($from_days_before - 1 . ' days ago');
     $last_commit = $repository->getLastcommit();
     $beginning_of_day = $from->beginningOfDay();
     $max_commits = Commits::count(array("parent_id = ? AND created_on >= ? GROUP BY DAY(created_on) ORDER BY row_count DESC LIMIT 1", $repository->getId(), $beginning_of_day));
     $from_days_before--;
     for ($i = $from_days_before; $i >= 0; $i--) {
         $date = new DateTimeValue($i . 'days ago');
         $this_date_beginning = $date->beginningOfDay();
         $this_date_end = $date->endOfDay();
         $commits_count = Commits::count(array("parent_id = ? AND created_on >= ? AND created_on <= ?", $repository->getId(), $this_date_beginning, $this_date_end));
         $activity[$i]['commits'] = $commits_count;
         $activity[$i]['created_on'] = date('F d, Y', $date->getTimestamp());
         $activity[$i]['percentage'] = round($commits_count * 100 / $max_commits);
     }
     return $activity;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:25,代码来源:Commits.class.php

示例2: getRangeContactsByBirthday

 function getRangeContactsByBirthday($from, $to, $tags = '', $project = null)
 {
     if (!$from instanceof DateTimeValue || !$to instanceof DateTimeValue || $from->getTimestamp() > $to->getTimestamp()) {
         return array();
     }
     $from = new DateTimeValue($from->getTimestamp());
     $from->beginningOfDay();
     $to = new DateTimeValue($to->getTimestamp());
     $to->endOfDay();
     $year1 = $from->getYear();
     $year2 = $to->getYear();
     if ($year1 == $year2) {
         $condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' AND DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
     } else {
         if ($year2 - $year1 == 1) {
             $condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' OR DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
         } else {
             $condition = "`birthday` <> '0000-00-00 00:00:00'";
         }
     }
     return $this->getAllowedContacts($condition);
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:22,代码来源:Contacts.class.php

示例3: isToday

 /**
  * This function will return true if this day is today
  *
  * @param integer $offset
  * @return boolean
  */
 function isToday($offset = null)
 {
     $today = new DateTimeValue(time() + $offset);
     $today->beginningOfDay();
     return $this->getDay() == $today->getDay() && $this->getMonth() == $today->getMonth() && $this->getYear() == $today->getYear();
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:12,代码来源:DateValue.class.php

示例4: getRangeContactsByBirthday

 function getRangeContactsByBirthday($from, $to, $member_ids = null)
 {
     if (!$from instanceof DateTimeValue || !$to instanceof DateTimeValue || $from->getTimestamp() > $to->getTimestamp()) {
         return array();
     }
     $from = new DateTimeValue($from->getTimestamp());
     $from->beginningOfDay();
     $to = new DateTimeValue($to->getTimestamp());
     $to->endOfDay();
     $year1 = $from->getYear();
     $year2 = $to->getYear();
     if ($year1 == $year2) {
         $condition = 'DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' AND DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . ')';
     } else {
         if ($year2 - $year1 == 1) {
             $condition = '(DAYOFYEAR(`birthday`) >= DAYOFYEAR(' . DB::escape($from) . ')' . ' OR DAYOFYEAR(`birthday`) <= DAYOFYEAR(' . DB::escape($to) . '))';
         } else {
             $condition = "`birthday` <> '0000-00-00 00:00:00'";
         }
     }
     if (!is_null($member_ids) && count($member_ids) > 0) {
         $condition .= " AND object_id IN (SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om WHERE om.member_id IN (" . implode(',', $member_ids) . "))";
     }
     return $this->getAllowedContacts($condition);
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:25,代码来源:Contacts.class.php


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