本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}