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


PHP Carbon::subDay方法代码示例

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


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

示例1: queuePreMatchEmail

 private function queuePreMatchEmail(\PlayFooty\Event $event)
 {
     Log::info(__METHOD__);
     $reminderDate = new Carbon($event->event_date . " " . $event->start_time);
     $reminderDate->subDay(1);
     Queue::later($reminderDate, new SendOrganiserReminderEmail($event));
 }
开发者ID:jameshd,项目名称:playfooty,代码行数:7,代码来源:MatchesController.php

示例2: expenseAccounts

 /**
  * @param Collection $accounts
  * @param Carbon     $start
  * @param Carbon     $end
  *
  * @return array
  */
 public function expenseAccounts(Collection $accounts, Carbon $start, Carbon $end)
 {
     $data = ['count' => 1, 'labels' => [], 'datasets' => [['label' => trans('firefly.spent'), 'data' => []]]];
     bcscale(2);
     $start->subDay();
     $ids = $this->getIdsFromCollection($accounts);
     $startBalances = Steam::balancesById($ids, $start);
     $endBalances = Steam::balancesById($ids, $end);
     $accounts->each(function (Account $account) use($startBalances, $endBalances) {
         $id = $account->id;
         $startBalance = $this->isInArray($startBalances, $id);
         $endBalance = $this->isInArray($endBalances, $id);
         $diff = bcsub($endBalance, $startBalance);
         $account->difference = round($diff, 2);
     });
     $accounts = $accounts->sortByDesc(function (Account $account) {
         return $account->difference;
     });
     foreach ($accounts as $account) {
         if ($account->difference > 0) {
             $data['labels'][] = $account->name;
             $data['datasets'][0]['data'][] = $account->difference;
         }
     }
     return $data;
 }
开发者ID:zetaron,项目名称:firefly-iii,代码行数:33,代码来源:ChartJsAccountChartGenerator.php

示例3: getBeginningAndEndingWeekDates

 /**
  * @param $dateSelected
  *
  * @return array
  */
 protected function getBeginningAndEndingWeekDates($dateSelected)
 {
     $dateSelected = $this->deriveDateSelected($dateSelected);
     $bwDate = new Carbon($dateSelected);
     if ($bwDate->dayOfWeek == 0) {
         $ewDate = new Carbon($bwDate);
         $iso_beginning_dow_date = new Carbon($bwDate);
         $ewDate->addDays(6);
     } else {
         $bwDate->startOfWeek();
         // iso standard; Monday is the start of week.
         $iso_beginning_dow_date = new Carbon($bwDate);
         $bwDate->subDay();
         // adjust to Sunday as this is our current offset.
         $ewDate = new Carbon($bwDate);
         $ewDate->addDays(6);
     }
     return [$bwDate, $ewDate, $iso_beginning_dow_date];
 }
开发者ID:RichJones22,项目名称:TimeTrax,代码行数:24,代码来源:TimeCardController.php

示例4: visitorDiagramInfo

 private function visitorDiagramInfo(Article $article)
 {
     $chartDatas = Visit::select([DB::raw('DATE(created_at) AS date'), DB::raw('COUNT(id) AS count')])->whereBetween('created_at', [Carbon::now()->subDays(30), Carbon::now()])->where('visitable_id', $article->id)->where('visitable_type', 'App\\Article')->groupBy('date')->orderBy('date', 'ASC')->get();
     $chartDataByDay = [];
     $chartDataByDayShamsi = [];
     foreach ($chartDatas as $data) {
         $chartDataByDay[$data->date] = $data->count;
     }
     $date = new Carbon();
     for ($i = 0; $i < 30; $i++) {
         $dateString = $date->format('Y-m-d');
         if (!isset($chartDataByDay[$dateString])) {
             $chartDataByDay[$dateString] = 0;
         }
         $date->subDay();
     }
     //        foreach($chartDataByDay as $date=>$value){
     //            $chartDataByDayShamsi[jDate::forge($date)->format('date')] = $value;
     //        }
     return $chartDataByDay;
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:21,代码来源:ArticleController.php

示例5: showOverviewChart

 /**
  * Same but a longer date range
  * TODO combine and smarter call.
  * @param type $id
  * @return type
  */
 public function showOverviewChart($object, $id = 0)
 {
     $key = cacheKey($object, 'overviewChart', $id, Session::get('period'));
     if (Cache::has($key)) {
         return Response::json(Cache::get($key));
     }
     $objects = Str::plural($object);
     $today = clone Session::get('period');
     $end = clone $today;
     $end->modify('last day of this month');
     $past = self::getFirst();
     $db = Auth::user()->{$objects}()->find($id);
     if ($object == 'budget') {
         $past = new Carbon($db->date);
         $past->subDay();
     }
     $data = array('cols' => array(array('id' => 'date', 'label' => 'Date', 'type' => 'date', 'p' => array('role' => 'domain')), array('id' => 'amount', 'label' => 'Amount', 'type' => 'number', 'p' => array('role' => 'data')), array('type' => 'boolean', 'p' => array('role' => 'certainty'))), 'rows' => array());
     $index = 0;
     // exceptions?
     switch ($object) {
         default:
             break;
         case 'account':
             $amount = $db->balance($past);
             break;
         case 'budget':
             $balance = $db->amount;
             // get the prediction points (if any):
             $points = $db->budgetpredictionpoints()->get();
             $prediction = array();
             foreach ($points as $p) {
                 $prediction[intval($p->day)] = floatval($p->amount);
             }
             break;
     }
     while ($past <= $end) {
         $month = intval($past->format('n')) - 1;
         $year = intval($past->format('Y'));
         $day = intval($past->format('j'));
         $data['rows'][$index]['c'][0]['v'] = 'Date(' . $year . ', ' . $month . ', ' . $day . ')';
         // exceptions?
         switch ($object) {
             default:
                 // let's actually do the defaults:
                 $transactions = floatval($db->transactions()->where('onetime', '=', 0)->where('date', '=', $past->format('Y-m-d'))->sum('amount'));
                 $sum = $transactions;
                 $data['rows'][$index]['c'][1]['v'] = $sum;
                 $data['rows'][$index]['c'][2]['v'] = true;
                 break;
             case 'budget':
                 if ($past <= $today) {
                     $balance = $db->left($past);
                     $data['rows'][$index]['c'][1]['v'] = $balance;
                     $data['rows'][$index]['c'][2]['v'] = true;
                 } else {
                     $balance = $balance - (isset($prediction[$day]) ? $prediction[$day] : 0);
                     $data['rows'][$index]['c'][1]['v'] = $balance;
                     $data['rows'][$index]['c'][2]['v'] = false;
                 }
                 break;
             case 'beneficiary':
                 $transactions = floatval(Auth::user()->transactions()->where('beneficiary_id', '=', $db->id)->where('date', '=', $past->format('Y-m-d'))->sum('amount'));
                 $data['rows'][$index]['c'][1]['v'] = $transactions;
                 $data['rows'][$index]['c'][2]['v'] = true;
                 break;
             case 'account':
                 if ($past > $today) {
                     $prediction = $db->predict($past);
                     $balance = $balance - $prediction;
                     $certain = false;
                 } else {
                     $balance = $db->balance($past);
                     $certain = true;
                 }
                 $data['rows'][$index]['c'][1]['v'] = $balance;
                 $data['rows'][$index]['c'][2]['v'] = $certain;
                 break;
         }
         $past->addDay();
         $index++;
     }
     Cache::put($key, $data, 1440);
     return Response::json($data);
 }
开发者ID:jcyh,项目名称:nder-firefly,代码行数:90,代码来源:OverviewController.php


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