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


PHP Carbon::firstOfMonth方法代码示例

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


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

示例1: monthlyLogs

 public function monthlyLogs(Carbon $date, $branch)
 {
     $arr = [];
     $fr = $date->firstOfMonth();
     $to = $date->copy()->lastOfMonth();
     $data = $this->aggregateDailyLogs($fr, $to, $branch->id);
     for ($i = 0; $i < $date->daysInMonth; $i++) {
         $date = $fr->copy()->addDays($i);
         $filtered = $data->filter(function ($item) use($date) {
             return $item->filedate->format('Y-m-d') == $date->format('Y-m-d') ? $item : null;
         });
         $b = $filtered->first();
         if (!is_null($b)) {
             $e = file_exists(config('filesystems.disks.backup.' . app()->environment() . '.root') . $branch->code . DS . $b->year . DS . $b->filedate->format('m') . DS . $b->filename);
         } else {
             $e = 0;
         }
         array_push($arr, ['date' => $date, 'backup' => $b, 'exist' => $e]);
     }
     return $arr;
 }
开发者ID:jrsalunga,项目名称:gi-boss,代码行数:21,代码来源:BackupRepository.php

示例2: each

echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no");
printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no");
printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no");
printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no");
// first and last of the month
printf("First of the month %s\n", $dtBerlin->firstOfMonth());
printf("Last of the month %s\n", $dtBerlin->lastOfMonth());
// nthOf* function test
printf("Start of the month %s\n", $dtBerlin->startOfMonth());
printf("End of the month %s\n", $dtBerlin->endOfMonth());
printf("End of the decade %s\n", $dtBerlin->endOfDecade());
// Date manipulation
print $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3);
print $dtBerlin->subMonths(8)->subHours(7);
// Find UK Bank Holidays
$dtLondon = CitcoCarbon::today('Europe/London');
list($date, $name) = each($dtLondon->nextBankHoliday());
printf("The next bank holiday is %s on %s\n", $name, $date);
foreach ($dtLondon->getBankHolidays([2016, 2017]) as $date => $name) {
    printf("The next bank holiday is %s on %s\n", $name, $date);
}
开发者ID:settermjd,项目名称:carbon-experiments,代码行数:31,代码来源:index.php

示例3: each

echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
echo "Is yesterday? " . ($dtBerlin->isYesterday() ? "yes" : "no") . PHP_EOL;
echo "Is a Thursday? " . ($dtBerlin->isThursday() ? "yes" : "no") . PHP_EOL;
echo "Is in the future? " . ($dtBerlin->isFuture() ? "yes" : "no") . PHP_EOL;
echo "Is a leap year? " . ($dtBerlin->isLeapYear() ? "yes" : "no") . PHP_EOL;
// first and last of the month
echo "First of the month " . $dtBerlin->firstOfMonth() . PHP_EOL;
echo "Last of the month " . $dtBerlin->lastOfMonth() . PHP_EOL;
// nthOf* function test
echo "Start of the month ", $dtBerlin->startOfMonth() . PHP_EOL;
echo "End of the month ", $dtBerlin->endOfMonth() . PHP_EOL;
echo "End of the decade ", $dtBerlin->endOfDecade() . PHP_EOL;
// Date manipulation
echo $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3) . PHP_EOL;
echo $dtBerlin->subMonths(8)->subHours(7) . PHP_EOL;
// Find UK Bank Holidays
$dtLondon = CitcoCarbon::today('Europe/London');
list($date, $name) = each($dtLondon->nextBankHoliday());
printf("The next bank holiday is %s on %s\n", $name, $date);
foreach ($dtLondon->getBankHolidays([2016, 2017]) as $date => $name) {
    printf("The next bank holiday is %s on %s\n", $name, $date);
}
开发者ID:omerida,项目名称:carbon-experiments,代码行数:31,代码来源:index.php

示例4: findOfMonth

 /**
  * @param Carbon $date
  * @return \Illuminate\Support\Collection
  */
 public function findOfMonth(Carbon $date)
 {
     $startDate = $date->firstOfMonth()->format(MYSQL_DATE_FORMAT);
     $endDate = $date->lastOfMonth()->format(MYSQL_DATE_FORMAT);
     $schedules = $this->findByDateInterval($startDate, $endDate);
     return $schedules;
 }
开发者ID:filmoteca,项目名称:filmoteca,代码行数:11,代码来源:SchedulesRepository.php

示例5: countContractTotal

 /**
  * Count total Contracts
  *
  * @param string $date
  * @return contract
  */
 public function countContractTotal($date = '')
 {
     switch ($date) {
         case 'today':
             $dateFormat = $this->carbon->today()->toDateString();
             break;
         case 'yesterday':
             $dateFormat = $this->carbon->yesterday()->toDateString();
             break;
         case 'this_month':
             $dateFormat = [$this->carbon->firstOfMonth()->toDateString(), $this->carbon->now()->toDateString()];
             break;
         case 'last_month':
             $dateFormat = [$this->carbon->now()->subMonth(1)->firstOfMonth()->toDateString(), $this->carbon->now()->subMonth(1)->endOfMonth()->toDateString()];
             break;
         default:
             $dateFormat = '';
             break;
     }
     return $this->contract->countTotal($dateFormat);
 }
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:27,代码来源:DashboardService.php


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