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


PHP Date::copy方法代碼示例

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


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

示例1: getSubscribers

 /**
  * Fetches all of the subscribers over the last 30 days.
  *
  * @return \Illuminate\Support\Collection
  */
 protected function getSubscribers()
 {
     $allSubscribers = Subscriber::whereBetween('created_at', [$this->startDate->copy()->subDays(30)->format('Y-m-d') . ' 00:00:00', $this->startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) {
         return (new Date($incident->created_at))->setTimezone($this->dateTimeZone)->toDateString();
     });
     // Add in days that have no incidents
     foreach (range(0, 30) as $i) {
         $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
         if (!isset($allSubscribers[$date->toDateString()])) {
             $allSubscribers[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allSubscribers = $allSubscribers->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, false);
     return $allSubscribers;
 }
開發者ID:practico,項目名稱:Cachet,代碼行數:23,代碼來源:DashboardController.php


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