本文整理汇总了PHP中Carbon\Carbon::endOfMonth方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::endOfMonth方法的具体用法?PHP Carbon::endOfMonth怎么用?PHP Carbon::endOfMonth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::endOfMonth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
public function Execute()
{
$conn = \ZCL\DB\DB::getConnect();
$store_id = $this->headerdata['store_id'];
$item = \ZippyERP\ERP\Entity\Item::getSumItem();
$stock = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
$discont = 0;
//скидки 704 счет
$date = new Carbon();
$date->setTimestamp($this->document_date);
$end = $date->endOfMonth()->getTimestamp();
$begin = $date->startOfMonth()->getTimestamp();
$sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0 and account_id=285 and extcode = {$store_id} and document_date <= " . $conn->DBDate($end);
$tm = $conn->GetOne($sql);
//торговая наценка на конец периода
//остатки на конец периода
$sql = " select coalesce(sum(quantity),0) AS quantity,coalesce(price,0) as price from erp_account_subconto sc join erp_store_stock st on sc.stock_id = st.stock_id where store_id = {$store_id} and date(document_date) <= " . $conn->DBDate($end);
$row = $conn->GetRow($sql);
$ost = $row['quantity'] / 1000;
$ost = $ost * $row['price'];
if ($ost == 0) {
return;
}
//выручка
$sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0 and account_id=702 and extcode = {$store_id} and date(document_date) <= " . $conn->DBDate($end) . " and date(document_date) >= " . $conn->DBDate($begin);
$saled = $conn->GetOne($sql);
//выручка сданная в кассу
$k = ($tm - $discont) / ($ost - $discont);
$sb = (1 - $k) * $saled;
//себестоимость
// списываем наценку
Entry::AddEntry("285", "282", $saled - $sb, $this->document_id, $this->document_date);
// себестоимость реализации
Entry::AddEntry("902", "282", $sb, $this->document_id, $this->document_date);
$item = \ZippyERP\ERP\Entity\Item::getSumItem();
$stockto = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
$sc = new SubConto($this, 282, 0 - $saled);
$sc->setStock($stockto->stock_id);
$sc->setQuantity(0 - $saled * 1000);
//цена единицы товара - 1 копейка.
$sc->save();
// НДС
$nds = H::nds(true);
Entry::AddEntry("702", "641", $saled * $nds, $this->document_id, $this->document_date);
return true;
}
示例2: getDefaultJsOptions
/**
* Returns default javascript options
*
* Available options:
* @see https://github.com/dangrossman/bootstrap-daterangepicker#options
*
* @return array
*/
protected function getDefaultJsOptions()
{
$carbon = new Carbon();
$prev_month = Carbon::now()->startOfMonth()->subWeek();
$today = Carbon::now();
$res = ['format' => 'YYYY-MM-DD', 'ranges' => ['previous_month' => ['Previous month (' . $prev_month->format('F') . ')', [$prev_month->startOfMonth()->format('Y-m-d'), $prev_month->endOfMonth()->format('Y-m-d')]], 'current_month' => ['Cur. month (' . date('F') . ')', [$carbon->startOfMonth()->format('Y-m-d'), $carbon->endOfMonth()->format('Y-m-d')]], 'last_week' => ['This Week', [$carbon->startOfWeek()->format('Y-m-d'), $carbon->endOfWeek()->format('Y-m-d')]], 'last_14' => ['Last 14 days', [Carbon::now()->subDays(13)->format('Y-m-d'), $today->format('Y-m-d')]]]];
// will not set dates when '' passed but set default date when null passed
if ($this->getStartValue()) {
$res['startDate'] = $this->getStartValue();
}
if ($this->getEndValue()) {
$res['endDate'] = $this->getEndValue();
}
return $res;
}
示例3: each
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);
}
// Find end of the current financial year
$fyCalculator = new Calculator(7, 1);
/* FY starts on July 1 */
print $fyCalculator->get($dtBerlin);
示例4: getDefaultJsOptions
/**
* Returns default javascript options
*
* Available options:
* @see https://github.com/dangrossman/bootstrap-daterangepicker#options
*
* @return array
*/
protected function getDefaultJsOptions()
{
$carbon = new Carbon();
$prev_month = Carbon::now()->startOfMonth()->subWeek();
$today = Carbon::now();
return ['format' => 'YYYY-MM-DD', 'ranges' => ['previous_month' => ['Previous month (' . $prev_month->format('F') . ')', [$prev_month->startOfMonth()->format('Y-m-d'), $prev_month->endOfMonth()->format('Y-m-d')]], 'current_month' => ['Cur. month (' . date('F') . ')', [$carbon->startOfMonth()->format('Y-m-d'), $carbon->endOfMonth()->format('Y-m-d')]], 'last_week' => ['This Week', [$carbon->startOfWeek()->format('Y-m-d'), $carbon->endOfWeek()->format('Y-m-d')]], 'last_14' => ['Last 14 days', [Carbon::now()->subDays(13)->format('Y-m-d'), $today->format('Y-m-d')]]], 'startDate' => $this->getStartValue(), 'endDate' => $this->getEndValue()];
}
示例5: scopeThismonth
public function scopeThismonth($query)
{
$carbon = new Carbon();
return $query->whereBetween(DB::raw('date(task_date)'), [$carbon->startOfMonth()->format('y-m-d'), $carbon->endOfMonth()->format('Y-m-d')])->get();
}
示例6: energyUseYear
/**
* @param Device $device
*
* @return \Illuminate\Http\JsonResponse
*/
public function energyUseYear(Device $device)
{
$chart = App::make('gchart');
$chart->addColumn('Date', 'date');
$chart->addColumn('Leaf time', 'number');
$chart->addColumn('Heating', 'number');
$chart->addColumn('Outside temperature', 'number');
$city = City::findCity($device->structure->postal_code, $device->structure->country_code);
$today = new Carbon();
$today->endOfMonth()->addDay();
$lastMonth = clone $today;
$lastMonth->subYear();
while ($lastMonth < $today) {
// get is_heating_on and has_leaf for this day:
$entry = $device->logEntries()->inMonth($lastMonth)->withLogValue('has_leaf')->withLogValue('is_heating_on')->first([DB::Raw('sum(has_leaf.value) / 12 as has_leaf'), DB::Raw('sum(is_heating_on.value) / 12 as is_heating_on')]);
$heating = null;
$leaftime = null;
$outside = null;
// if both are null, get data from summaries instead:
if (!is_null($entry->has_leaf) && !is_null($entry->is_heating_on)) {
$heating = floatval($entry->is_heating_on);
$leaftime = floatval($entry->has_leaf);
} else {
// get summaries (or try at least):
$entry = $device->summaryEntries()->inMonth($lastMonth)->withSummaryValue('has_leaf')->withSummaryValue('is_heating_on')->first([DB::Raw('sum(has_leaf.value) / 60 as has_leaf'), DB::Raw('sum(is_heating_on.value) / 60 as is_heating_on')]);
$heating = is_null($entry->is_heating_on) ? null : floatval($entry->is_heating_on);
$leaftime = is_null($entry->has_leaf) ? null : floatval($entry->has_leaf);
}
// get weather for city:
$report = $city->reports()->inMonth($lastMonth)->withReportValue('main.temp')->first([DB::Raw('avg(main_temp.value) as main_temp')]);
if (!is_null($report)) {
$outside = !is_null($report->main_temp) ? floatval($report->main_temp) : null;
}
$chart->addRow(clone $lastMonth, $leaftime, $heating, $outside);
$lastMonth->endOfMonth()->addDay();
}
$chart->generate();
return Response::json($chart->getData());
}
示例7: getDefaultJsOptions
/**
* Returns default javascript options
*
* Available options:
* @see https://github.com/dangrossman/bootstrap-daterangepicker#options
*
* @return array
*/
protected function getDefaultJsOptions()
{
$carbon = new Carbon();
$prev_month = Carbon::now()->startOfMonth()->subWeek();
$today = Carbon::today();
$yesterday = Carbon::yesterday();
$res = ['format' => 'YYYY-MM-DD', 'ranges' => ['Today' => [$today->format('Y-m-d'), $today->format('Y-m-d')], 'Previous Day' => [$yesterday->format('Y-m-d'), $yesterday->format('Y-m-d')], 'This Week' => [$carbon->startOfWeek()->format('Y-m-d'), $carbon->endOfWeek()->format('Y-m-d')], 'This Month (' . date('F') . ')' => [$carbon->startOfMonth()->format('Y-m-d'), $carbon->endOfMonth()->format('Y-m-d')], 'Previous Month (' . $prev_month->format('F') . ')' => [$prev_month->startOfMonth()->format('Y-m-d'), $prev_month->endOfMonth()->format('Y-m-d')]]];
$res['opens'] = 'left';
// will not set dates when '' passed but set default date when null passed
if ($this->getStartValue()) {
$res['startDate'] = $this->getStartValue();
}
if ($this->getEndValue()) {
$res['endDate'] = $this->getEndValue();
}
return $res;
}
示例8: each
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);
}
// Find end of the current financial year
$fyCalculator = new Calculator(7, 1);
/* FY starts on July 1 */
print $fyCalculator->get($dtBerlin);