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


PHP Carbon::setTime方法代码示例

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


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

示例1: getExtend

 public function getExtend($uid, $period)
 {
     /* @var $user User */
     $user = User::find($uid);
     if (empty($user->announcement_stream)) {
         Flash::error('Пользователь не подписан на рассылку.');
         return Redirect::to('admin/subscriptions');
     }
     // Already has an active subscription.
     if ($user->announcement_expires && $user->announcement_expires->isFuture()) {
         $user->announcement_expires = $user->announcement_expires->addDays($period);
     }
     // Subscription expired.
     if ($user->announcement_expires && $user->announcement_expires->isPast()) {
         // Start tomorrow.
         $start = new Carbon();
         $start->setTime(0, 0, 0)->addDays(1);
         $user->announcement_start = $start;
         // Expire in $period from tomorrow.
         $expires = clone $start;
         $expires->addDays($period);
         $user->announcement_expires = $expires;
     }
     $user->save();
     Flash::success('Подписка продленна.');
     return Redirect::to('admin/subscriptions');
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:27,代码来源:SubscriptionsController.php

示例2: store

 public function store()
 {
     $id = $this->request->input('id');
     $input = $this->request->only(['provider', 'text', 'link', 'image']);
     $categories = $this->request->input('categories');
     $inputSchedule = $this->request->only(['schedule_date', 'schedule_time']);
     if ($input['provider'] == 'weblink' && !$input['link']) {
         throw new Exception('The "link" argument is missing', 1);
     }
     $post = (int) $id ? Post::find($id)->fill($input) : new Post($input);
     if ($inputSchedule['schedule_date']) {
         $time = explode(':', $inputSchedule['schedule_time']);
         $date = new Carbon($inputSchedule['schedule_date']);
         if (count($time) > 1) {
             $date->setTime($time[0], $time[1]);
         }
         if ($date->timestamp > time()) {
             $post->posted_at = $date;
         }
     } else {
         $post->posted_at = new Carbon();
     }
     $post->user_id = $this->auth->id();
     $post->save();
     if (count($categories)) {
         $post->categories()->sync($categories);
     } else {
         $post->categories()->detach();
     }
     $post->provider_id = $post->id;
     $success = $post->save();
     $job = (new PublishPost($post))->onQueue('publish');
     $queued = $this->dispatch($job);
     return compact('success', 'queued');
 }
开发者ID:net-shell,项目名称:socialsync,代码行数:35,代码来源:PostController.php

示例3: getUsers

 protected function getUsers($days)
 {
     $expires = new Carbon();
     $expires->setTime(0, 0, 0)->addDays($days);
     $expires = $expires->format('Y-m-d H:i:s');
     $users = User::where('announcement_expires', '=', $expires)->get();
     return $users;
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:8,代码来源:SubscriptionReminder.php

示例4: getFirstDate

 /**
  *
  * Returns date (Carbon object) set to the date of the very first post
  * or to current date if there are no posts
  *
  * @return Carbon
  */
 protected static function getFirstDate()
 {
     $post = BlogPost::orderBy('published_at', 'asc')->isPublished()->first();
     if (!$post) {
         $date = new Carbon();
     } else {
         $date = new Carbon($post->published_at);
     }
     $date->setTime(0, 0);
     return $date;
 }
开发者ID:graker,项目名称:blogarchive,代码行数:18,代码来源:ArchiveTrait.php

示例5: get

 /**
  * Get the FY end date
  *
  * @param Carbon $dt Date to determine FY for
  *
  * @return Carbon Carbon instance set to the end of the FY for the input
  */
 public function get(Carbon $dt = NULL)
 {
     if (!$dt) {
         $dt = new Carbon();
     }
     /* Disregard times */
     $dt->setTime(0, 0, 0);
     /* FY is based on the -end- of the FY, thus we will work backward to determine if we need to 'rollup' the FY
        from the input year */
     $fyStart = Carbon::create($dt->year, $this->month, $this->day, 0, 0, 0);
     $fyEnd = clone $fyStart;
     $fyEnd->addYear()->subDay();
     if (!$dt->between($fyStart, $fyEnd, TRUE)) {
         $fyEnd->year($dt->year);
     }
     return $fyEnd;
 }
开发者ID:rovangju,项目名称:carbon-fy,代码行数:24,代码来源:Calculator.php

示例6: getCurrentRange

 /**
  *
  * Returns with start and end dates limiting current archive output
  *
  * @return Carbon[] - [start, end]
  */
 protected function getCurrentRange()
 {
     if (!$this->year) {
         return [];
     }
     $start = new Carbon();
     $end = new Carbon();
     if (!$this->month) {
         //year archive
         $start->setDate($this->year, 1, 1);
         $end->setDate(intval($this->year) + 1, 1, 1);
     } else {
         if (!$this->day) {
             //month archive
             $start->setDate($this->year, $this->month, 1);
             $end->setDate($this->year, intval($this->month) + 1, 1);
         } else {
             //day archive
             $start->setDate($this->year, $this->month, $this->day);
             $end->setDate($this->year, $this->month, intval($this->day) + 1);
         }
     }
     $start->setTime(0, 0, 0);
     $end->setTime(0, 0, 0);
     return [$start, $end];
 }
开发者ID:graker,项目名称:blogarchive,代码行数:32,代码来源:BlogArchive.php

示例7: getLatestEnd

 /**
  * Get the latest end time for an event on a particular day.
  * @param \Carbon\Carbon $date
  * @return string
  */
 public function getLatestEnd(Carbon $date)
 {
     $date->setTime(00, 00, 00);
     foreach ($this->times as $time) {
         if ($time->end->isSameDay($date) && $time->end->gt($date)) {
             $date->setTime($time->end->hour, $time->end->minute, $time->end->second);
         }
     }
     return $date->format('H:i');
 }
开发者ID:backstagetechnicalservices,项目名称:website,代码行数:15,代码来源:Event.php

示例8: addExclusion

 /**
  * Add a date to exclude as a business day
  *
  * @param $exclusion string|Carbon
  */
 public function addExclusion(Carbon $exclusion)
 {
     $exclusion->setTime(0, 0, 0);
     $this->exclusions[] = $exclusion;
 }
开发者ID:rovangju,项目名称:carbon-nbd,代码行数:10,代码来源:Calculator.php

示例9: setupDayPager

 /**
  * Sets up pager to switch prev/next day
  */
 protected function setupDayPager()
 {
     $first_date = $this->first_date;
     $current_date = $this->current_date;
     // previous
     if ($first_date->getTimestamp() < $current_date->getTimestamp()) {
         $previous_date = $current_date->copy();
         $previous_date->subDay(1);
         $this->previous_text = $previous_date->formatLocalized('%d') . ' ' . $previous_date->formatLocalized('%B') . ', ' . $previous_date->year;
         $this->previous_url = $this->makePagerUrl(array('year' => $previous_date->year, 'month' => $previous_date->month, 'day' => $previous_date->day));
     } else {
         $this->previous_text = $current_date->formatLocalized('%d') . ' ' . $current_date->formatLocalized('%B') . ', ' . $current_date->year;
         $this->previous_url = '';
     }
     // next
     $today = new Carbon();
     $today->setTime(0, 0);
     if ($this->current_date->getTimestamp() < $today->getTimestamp()) {
         $next_date = $current_date->copy();
         $next_date->addDay(1);
         $this->next_text = $next_date->formatLocalized('%d') . ' ' . $next_date->formatLocalized('%B') . ', ' . $next_date->year;
         $this->next_url = $this->makePagerUrl(array('year' => $next_date->year, 'month' => $next_date->month, 'day' => $next_date->day));
     } else {
         $this->next_text = $current_date->formatLocalized('%d') . ' ' . $current_date->formatLocalized('%B') . ', ' . $current_date->year;
         $this->next_url = '';
     }
 }
开发者ID:graker,项目名称:blogarchive,代码行数:30,代码来源:ArchivePager.php

示例10: findUsersByCreatedDate

 public function findUsersByCreatedDate(Carbon $fromDate, Carbon $toDate, $userType)
 {
     $toDate->setTime(23, 59);
     $isEmpty = $userType == 'agent' ? '<>' : '=';
     return User::with('country')->whereBetween('created_at', [$fromDate, $toDate])->where('agency', $isEmpty, '')->get();
 }
开发者ID:skiwei,项目名称:sayangholidays,代码行数:6,代码来源:UserRepository.php


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