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


PHP Carbon::createFromTimestamp方法代码示例

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


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

示例1: expired

 public function expired($e)
 {
     $token = \JWTAuth::parseToken();
     Config::package('tymon/jwt-auth', 'jwt');
     $ttl = Config::get('jwt::refresh_ttl');
     $iat = Carbon::createFromTimestamp($token->getPayload()->get('iat'));
     $now = Carbon::now();
     // if renew ttl is expired too, return 401, otherwise let
     // the application generate a new token to frontend
     if ($iat->diffInMinutes($now) >= $ttl) {
         unset($iat, $now, $ttl);
         return response_failure(Lang::get('errors.api.auth.expired'), Config::get('status.error.unauthorized'));
     }
     unset($iat, $now, $ttl);
 }
开发者ID:josmel,项目名称:buen,代码行数:15,代码来源:ControllerWS.php

示例2: datetime

 public function datetime()
 {
     return Carbon::createFromTimestamp(Storage::disk('logs')->lastModified($this->filename));
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:4,代码来源:LogFile.php

示例3: formattedCreated

 public function formattedCreated()
 {
     $dt = Carbon::createFromTimestamp(strtotime($this->created_at));
     $date = $dt->format('d-m-y \\a\\t ga');
     // 05-11-2014 at 1pm
     return $date;
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:7,代码来源:BaseModel.php

示例4: fileModified

 /**
  * Return the last modified time
  */
 public function fileModified($path)
 {
     return Carbon::createFromTimestamp($this->disk->lastModified($path));
 }
开发者ID:jonioliveira,项目名称:prototype2015,代码行数:7,代码来源:UploadManager.php

示例5: createUser

 /**
  * Create a user
  *
  * @return Create user
  * @author Rajiv Seelam
  **/
 public function createUser($data, $activate = false)
 {
     $data['birthday'] = \Carbon::createFromTimestamp(strtotime($data['birthday']));
     $password = isset($data['password']) ? $data['password'] : str_random(10);
     $user = $this->sentry->createUser(array('email' => $data['email'], 'name' => $data['name'], 'password' => $password, 'activated' => $activate));
     if (in_array($data['gender'], ['male', 'female'])) {
         $user->gender = $data['gender'];
     }
     if ($data['birthday']) {
         $user->birthday = $data['birthday'];
     }
     if (isset($data['description'])) {
         $user->description = strip_tags($data['description']);
     }
     if (isset($data['image'])) {
         $user->photo = $data['image'];
     }
     $user->save();
     return $user;
 }
开发者ID:rajivseelam,项目名称:connect-laravel5-name,代码行数:26,代码来源:Connect.php

示例6: Subcription


//.........这里部分代码省略.........
                 }
                 $quarters_difference--;
                 $datediff = $quarters_difference;
                 break;
             case "m":
                 // Number of full months
                 $months_difference = floor($difference / 2678400);
                 while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom) + $months_difference, date("j", $dateto), date("Y", $datefrom)) < $dateto) {
                     $months_difference++;
                 }
                 $months_difference--;
                 $datediff = $months_difference;
                 break;
             case 'y':
                 // Difference between day numbers
                 $datediff = date("z", $dateto) - date("z", $datefrom);
                 break;
             case "d":
                 // Number of full days
                 $datediff = floor($difference / 86400);
                 break;
             case "w":
                 // Number of full weekdays
                 $days_difference = floor($difference / 86400);
                 $weeks_difference = floor($days_difference / 7);
                 // Complete weeks
                 $first_day = date("w", $datefrom);
                 $days_remainder = floor($days_difference % 7);
                 $odd_days = $first_day + $days_remainder;
                 // Do we have a Saturday or Sunday in the remainder?
                 if ($odd_days > 7) {
                     // Sunday
                     $days_remainder--;
                 }
                 if ($odd_days > 6) {
                     // Saturday
                     $days_remainder--;
                 }
                 $datediff = $weeks_difference * 5 + $days_remainder;
                 break;
             case "ww":
                 // Number of full weeks
                 $datediff = floor($difference / 604800);
                 break;
             case "h":
                 // Number of full hours
                 $datediff = floor($difference / 3600);
                 break;
             case "n":
                 // Number of full minutes
                 $datediff = floor($difference / 60);
                 break;
             default:
                 // Number of full seconds (default)
                 $datediff = $difference;
                 break;
         }
         return $datediff;
     }
     $fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
     switch ($frequency) {
         case 1:
             //Weekly
             $frequency = Frequency::find($frequency)->name;
             $recurrences = datediff("ww", $start, $end, false);
             $schedule = array();
             for ($x = 0; $x <= $recurrences; $x++) {
                 $schedule[] = Carbon::createFromTimestamp(strtotime($start))->addWeeks($x)->format('m/d/y ');
             }
             $recurrences = $x;
             $amount = $fmt->parse($due) / $x;
             break;
         case 2:
             //Every two weeks
             $frequency = Frequency::find($frequency)->name;
             $recurrences = round(datediff("ww", $start, $end, false)) / 2;
             $schedule = array();
             for ($x = 0; $x <= $recurrences; $x++) {
                 $schedule[] = Carbon::createFromTimestamp(strtotime($start))->addWeeks($x * 2)->format('m/d/y ');
             }
             $recurrences = $x;
             $amount = $fmt->parse($due) / $x;
             break;
         case 3:
             //Monthly
             $frequency = Frequency::find($frequency)->name;
             $recurrences = datediff("m", $start, $end, false);
             $schedule = array();
             for ($x = 0; $x <= $recurrences; $x++) {
                 $schedule[] = Carbon::createFromTimestamp(strtotime($start))->addMonths($x)->format('m/d/y ');
             }
             $recurrences = $x;
             $amount = $fmt->parse($due) / $x;
             break;
     }
     setlocale(LC_MONETARY, "en_US");
     $result = array("frequency" => $frequency, "start" => $start, "end" => $end, "subtotal" => money_format('%.2n', round($amount, 2)), "fee" => money_format('%.2n', round($amount / getenv("SV_FEE") - $amount, 2)), "total" => money_format('%.2n', round($amount / getenv("SV_FEE"), 2)), "recurrences" => $recurrences, "dates" => $schedule);
     $object = json_decode(json_encode($result), FALSE);
     return $object;
 }
开发者ID:illuminate3,项目名称:league-production,代码行数:101,代码来源:Plan.php

示例7: lastModifiedAsString

 /**
  * Returns the item last modification date as string.
  *
  * @return string Returns the item's last modification date as string.
  */
 public function lastModifiedAsString()
 {
     if (!($date = $this->lastModified)) {
         return null;
     }
     return Carbon::createFromTimestamp($date)->toFormattedDateString();
 }
开发者ID:mclkim,项目名称:webftp,代码行数:12,代码来源:FtpLibraryItem.php

示例8: offers

 public function offers($timestamp = 0)
 {
     $offers = Offer::whereDate('created_at', '>', Carbon::createFromTimestamp($timestamp))->get();
     return response()->json($offers->toArray(), 200, [], JSON_UNESCAPED_UNICODE);
 }
开发者ID:mazhuravlev,项目名称:olx-grabber,代码行数:5,代码来源:ApiController.php

示例9: getFilterCondition

 /**
  * Creates a condition string from the passed ExtJs filter definitions
  *
  * @param $filterString
  * @param array $matchExact
  * @param bool $returnString
  * @param array $callbacks
  * @return array|string
  * @throws \Exception
  */
 public static function getFilterCondition($filterString, $matchExact = ['id', 'o_id'], $returnString = true, $callbacks = [])
 {
     if (!$filterString) {
         return '';
     }
     $conditions = [];
     $filters = json_decode($filterString);
     $db = \Pimcore\Db::get();
     foreach ($filters as $f) {
         if ($f->type == 'string') {
             if (in_array($f->property, $matchExact)) {
                 $conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " = " . $db->quote($f->value) . ' ';
             } else {
                 $conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%") . ' ';
             }
         } elseif ($f->type == 'numeric') {
             if ($f->operator == 'eq') {
                 $symbol = ' = ';
             } elseif ($f->operator == 'lt') {
                 $symbol = ' < ';
             } elseif ($f->operator == 'gt') {
                 $symbol = ' > ';
             }
             $conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . $symbol . $db->quote($f->value) . ' ';
         } elseif ($f->type == 'date') {
             /**
              * make sure you pass the date as timestamp
              *
              * filter: {type : 'date',dateFormat: 'timestamp'}
              */
             $date = Carbon::createFromTimestamp($f->value)->setTime(0, 0, 0);
             if ($f->operator == 'eq') {
                 $conditions[$f->property][] = ' ' . $f->property . ' >= ' . $db->quote($date->getTimestamp());
                 $conditions[$f->property][] = ' ' . $f->property . ' <= ' . $db->quote($date->addDay(1)->subSecond(1)->getTimestamp());
             } elseif ($f->operator == 'lt') {
                 $conditions[$f->property][] = ' ' . $f->property . ' < ' . $db->quote($date->getTimestamp());
             } elseif ($f->operator == 'gt') {
                 $conditions[$f->property][] = ' ' . $f->property . ' > ' . $db->quote($date->addDay(1)->subSecond(1)->getTimestamp());
             }
         } else {
             throw new \Exception("Filer of type " . $f->type . " not jet supported.");
         }
     }
     $conditionsGrouped = [];
     foreach ($conditions as $fieldName => $fieldConditions) {
         if (count($fieldConditions) > 1) {
             $conditionsGrouped[$fieldName] = ' (' . implode(' AND ', $fieldConditions) . ') ';
         } else {
             $conditionsGrouped[$fieldName] = $fieldConditions[0];
         }
     }
     if ($returnString) {
         return implode(' OR ', $conditionsGrouped);
     } else {
         return $conditionsGrouped;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:67,代码来源:QueryParams.php

示例10: mirrorDay

 /**
  * mirrorDay
  * --------------------------------------------------
  * Trying to mirror the specific date, to our DB.
  * @param date The date on which we're mirroring.
  * --------------------------------------------------
  */
 private function mirrorDay($date)
 {
     foreach ($this->events as $key => $event) {
         $eventDate = Carbon::createFromTimestamp($event['created'])->toDateString();
         if ($eventDate == $date) {
             switch ($event['type']) {
                 case 'customer.subscription.created':
                     $this->handleSubscriptionCreation($event);
                     break;
                 case 'customer.subscription.updated':
                     $this->handleSubscriptionUpdate($event);
                     break;
                 case 'customer.subscription.deleted':
                     $this->handleSubscriptionDeletion($event);
                     break;
                 default:
             }
             /* Making sure we're done with the event. */
             unset($this->events[$key]);
         }
     }
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:29,代码来源:StripeLastMonthCalculator.php

示例11: deleted

 /**
  * gets deleted posts,question,answers
  * @param  array $filter
  * @return array|bool
  */
 public function deleted($filter = [])
 {
     try {
         if (isset($filter['last_updated'])) {
             $filter['deleted_at'] = \Carbon::createFromTimestamp($filter['last_updated'])->toDateTimeString();
         }
         $data['posts'] = $this->post->deleted($filter);
         $data['categories'] = $this->category->deleted($filter);
         return $data;
     } catch (\Exception $e) {
         $this->logger->error($e);
         return false;
     }
     return false;
 }
开发者ID:Shuvayatra,项目名称:migration-web,代码行数:20,代码来源:ApiService.php


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