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


PHP Carbon::createFromDate方法代码示例

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


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

示例1: getDatesInWeeksForMonth

 /**
  * Return all date in weeks for a month.
  *
  * @param  Carbon  $date           The month.
  * @param  integer $firstDayOfWeek The first day of the week.
  *
  * @return Array                   Array of dates.
  */
 public static function getDatesInWeeksForMonth(Carbon $date, $firstDayOfWeek)
 {
     Log::info('Get all dates in weeks for month.', compact('date', 'firstDayOfWeek'));
     $days = array();
     $date = $date->copy();
     $date->day = 1;
     // Get next month.
     $nextMonth;
     if ($date->month === 12) {
         $nextMonth = 1;
     } else {
         $nextMonth = $date->month + 1;
     }
     // Get first day of the first week.
     if ($date->dayOfWeek > $firstDayOfWeek) {
         $date->day = -($date->dayOfWeek - $firstDayOfWeek - 1);
     } else {
         if ($date->dayOfWeek < $firstDayOfWeek) {
             $date->day = -(6 - ($firstDayOfWeek - $date->dayOfWeek));
         }
     }
     // Get rest of the days in weeks until next month and before first day of week.
     while (!($date->month === $nextMonth && $date->dayOfWeek === $firstDayOfWeek)) {
         $days[] = Carbon::createFromDate($date->year, $date->month, $date->day);
         $date->day++;
     }
     return $days;
 }
开发者ID:vipervoid,项目名称:Pitimi,代码行数:36,代码来源:DateService.php

示例2: showCalendar

 public function showCalendar($year, $month)
 {
     $date = Carbon::createFromDate($year, $month, 1);
     $data = $this->getCommonData();
     $data['month'] = $date;
     $data['months'] = DateService::getMonths($date);
     $data['days'] = DateService::getDatesInWeeksForMonth($date, Carbon::MONDAY);
     return View::make('home', $data);
 }
开发者ID:vipervoid,项目名称:Pitimi,代码行数:9,代码来源:HomeController.php

示例3: createUsersPlayersTest

 public function createUsersPlayersTest($nbPlayer = 2)
 {
     // Set Php Time Out
     ini_set('max_execution_time', 300);
     //300 seconds = 5 minutes
     // Suppression des Users & Players de Test
     $deletedUsers = User::where('email', 'LIKE', '%aa.be')->delete();
     // Boucle
     $createdUsers = 0;
     $messageRetour = '';
     for ($u = 1; $u <= $nbPlayer; $u++) {
         // 1-Auto Values
         $autoNom = 'Player-' . $u;
         $autoPrenom = 'player ' . $u;
         $autoMail = 'player_' . $u . '@aa.be';
         // 2-Create User with role = Player (3)
         $user = new User();
         $user->email = $autoMail;
         $user->password = '1111';
         $user->username = $autoNom;
         $user->password_confirmation = '1111';
         $user->confirmation_code = md5(uniqid(mt_rand(), true));
         $user->confirmed = 1;
         if (!$user->save()) {
             $messageRetour .= 'Unable to create user ' . $user->email;
             $messageRetour .= print_r($user->errors());
             $messageRetour .= '<hr>';
         } else {
             $messageRetour .= $u . ' Created user ' . $user->email;
             $messageRetour .= '<hr>';
             $userRole = DB::table('roles')->where('name', '=', 'Player')->pluck('id');
             $user->roles()->attach($userRole);
             // 3-Create Player
             $userId = $user->id;
             $autoNation = rand(2, 4);
             $autoHcp = rand(0, 360) / 10;
             $autoLangue = rand(1, 3);
             $autoClub = rand(2, 7);
             $autosexe = rand(1, 2);
             $autoLicence = 'TEST' . $u;
             $year = rand(1950, 2006);
             $month = rand(1, 12);
             $day = rand(1, 28);
             Player::create(array('user_id' => $userId, 'nom' => $autoNom, 'prenom' => $autoPrenom, 'nation_id' => $autoNation, 'hcp' => $autoHcp, 'langue_id' => $autoLangue, 'club_id' => $autoClub, 'statusplayer_id' => 1, 'sexe_id' => $autosexe, 'naissance' => Carbon::createFromDate($year, $month, $day), 'licence' => $autoLicence));
             $createdUsers++;
         }
     }
     return $messageRetour;
 }
开发者ID:birdiebel,项目名称:G2016,代码行数:49,代码来源:UsersController.php

示例4: getTimeLine

 /**
  * Get a timeline from the first to the last message
  *
  * @param \Channel $channel
  *
  * @return array
  */
 public static function getTimeLine(\Channel $channel)
 {
     $timeline = [];
     // Fetch start and end time
     $firstMsg = \Message::where('channel', $channel->sid)->orderBy('ts', 'asc')->first();
     $lastMsg = \Message::where('channel', $channel->sid)->orderBy('ts', 'desc')->first();
     $firstDate = $firstMsg->getCarbon()->format('Y-m-d');
     $lastDate = $lastMsg->getCarbon()->format('Y-m-d');
     // Loop and add to timeline
     while (strtotime($firstDate) <= strtotime($lastDate)) {
         list($year, $month, $day) = explode('-', $firstDate);
         $timeline[$year][$month][$day] = \Carbon::createFromDate($year, $month, $day);
         $firstDate = date('Y-m-d', strtotime("+1 day", strtotime($firstDate)));
     }
     return $timeline;
 }
开发者ID:kenyiu,项目名称:slacklogs,代码行数:23,代码来源:Repository.php

示例5: setPricing

 function setPricing()
 {
     $pricing = array();
     $pricing['daily'] = $this->property->_est_rent_daily_price;
     $daily = $this->property->_est_rent_daily_price;
     $weekly = $this->property->_est_rent_weekly_price;
     $pricing['weekly'] = empty($weekly) ? $daily : $weekly / 7;
     $monthly = $this->property->_est_rent_monthly_price;
     $pricing['monthly'] = empty($monthly) ? $daily : $monthly / 30;
     $current = Carbon::createFromDate(2012, 1, 1);
     $end = Carbon::createFromDate(2013, 1, 1);
     $price_table = array();
     $seasonal_dates = !empty($this->seasonal_pricing) ? array_keys($this->seasonal_pricing) : array();
     while ($current->lt($end)) {
         $date = $current->format('m-d');
         if (!in_array($date, $seasonal_dates)) {
             $price_table[$date] = $pricing;
         } else {
             $price_table[$date] = $this->seasonal_pricing[$date];
         }
         $current->addDay();
     }
     $this->pricing = $price_table;
 }
开发者ID:SchaeferZone,项目名称:wp-estatement,代码行数:24,代码来源:BonsaiBooking.class.php

示例6: prettyDate

 public static function prettyDate($fecha)
 {
     $this->attributes['fecha'] = Carbon::createFromDate('d-m-Y', $fecha);
 }
开发者ID:jlobaton,项目名称:inventario,代码行数:4,代码来源:Enviado.php


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