本文整理汇总了PHP中Carbon\Carbon::startOfWeek方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::startOfWeek方法的具体用法?PHP Carbon::startOfWeek怎么用?PHP Carbon::startOfWeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::startOfWeek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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();
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()];
}
示例3: console
public function console()
{
$carbon = new Carbon();
$startOfWeek = $carbon->startOfWeek()->toDateTimeString();
$endOfWeek = $carbon->endOfWeek()->toDateTimeString();
$weekly = [$startOfWeek, $endOfWeek];
$subscribes = $this->subscribeRepository->count($weekly);
$publishingArticles = $this->publishingArticleRepository->count($weekly);
$contributeArticles = $this->contributeArticleRepository->count($weekly);
return view('dashboard.console', compact('subscribes', 'publishingArticles', 'contributeArticles'));
}
示例4: set_start
/**
* Set calendar start.
*
* @since 3.0.0
*
* @param int $timestamp
*/
public function set_start($timestamp = 0)
{
if (is_int($timestamp) && $timestamp !== 0) {
$this->start = $timestamp;
return;
}
$this->start = Carbon::now($this->timezone)->getTimestamp();
$calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true));
$nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth', true)), 1);
if ('today' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->getTimestamp();
} elseif ('days_before' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->subDays($nth)->getTimestamp();
} elseif ('days_after' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->addDays($nth)->getTimestamp();
} elseif ('this_week' == $calendar_begins) {
$week = new Carbon('now', $this->timezone);
$week->setWeekStartsAt($this->week_starts);
$this->start = $week->startOfWeek()->getTimestamp();
} elseif ('weeks_before' == $calendar_begins) {
$week = new Carbon('now', $this->timezone);
$week->setWeekStartsAt($this->week_starts);
$this->start = $week->startOfWeek()->subWeeks($nth)->getTimestamp();
} elseif ('weeks_after' == $calendar_begins) {
$week = new Carbon('now', $this->timezone);
$week->setWeekStartsAt($this->week_starts);
$this->start = $week->startOfWeek()->addWeeks($nth)->getTimestamp();
} elseif ('this_month' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->startOfMonth()->getTimeStamp();
} elseif ('months_before' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->getTimeStamp();
} elseif ('months_after' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->getTimeStamp();
} elseif ('this_year' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->startOfYear()->getTimestamp();
} elseif ('years_before' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->getTimeStamp();
} elseif ('years_after' == $calendar_begins) {
$this->start = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->getTimeStamp();
} elseif ('custom_date' == $calendar_begins) {
if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) {
$this->start = Carbon::createFromFormat('Y-m-d', esc_attr($date), $this->timezone)->setTimezone($this->timezone)->startOfDay()->getTimestamp();
}
}
}
示例5: 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];
}
示例6: 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;
}