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


PHP Carbon::toDateTimeString方法代码示例

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


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

示例1:

 function html_ago(Carbon $carbon, $id = null)
 {
     if ($id) {
         return '<abbr id="' . $id . '" class="timeago" title="' . $carbon->toISO8601String() . '">' . $carbon->toDateTimeString() . '</abbr>';
     }
     return '<abbr class="timeago" title="' . $carbon->toISO8601String() . '">' . $carbon->toDateTimeString() . '</abbr>';
 }
开发者ID:abcsun,项目名称:Credentials,代码行数:7,代码来源:helpers.php

示例2: toArray

 /**
  * @return array
  */
 public function toArray()
 {
     $filters = [];
     $filters[] = ['name' => 'from_date', 'value' => $this->fromDate->toDateTimeString()];
     $filters[] = ['name' => 'until_date', 'value' => $this->untilDate->toDateTimeString()];
     return $filters;
 }
开发者ID:mpociot,项目名称:cockpit,代码行数:10,代码来源:Filter.php

示例3: GetProfilePrices

 public function GetProfilePrices($id)
 {
     $date = new Carbon();
     $date->subDays(4);
     $prices = DB::table('profile_history_prices')->where('created_at', '>', $date->toDateTimeString())->where('profile_id', $id)->get(['created_at', 'price']);
     $hashtag = $this->GetProfileById($id);
     if ($hashtag->created_at > $date) {
         array_unshift($prices, array('price' => 0, 'created_at' => $hashtag->created_at->toDateTimeString()));
         array_unshift($prices, array('price' => 0, 'created_at' => $date->toDateTimeString()));
     }
     return $prices;
 }
开发者ID:krussll,项目名称:4oWj37LzO9,代码行数:12,代码来源:ProfilesRepository.php

示例4: addExternalAPILimitCounter

 /**
  * @param Carbon $now
  * @param string $externalApiName
  * @param int    $externalApiLimit
  * @param string $externalApiLimitInterval
  *
  * @return mixed
  */
 public function addExternalAPILimitCounter(Carbon $now, $externalApiName = 'test', $externalApiLimit = 100000, $externalApiLimitInterval = 'Day')
 {
     $ExternalApiLimit = ExternalApiLimit::where('external_api_name', $externalApiName)->where('external_api_limit_interval', $externalApiLimitInterval)->where('limit_interval_start', '<=', $now->toDateTimeString())->where('limit_interval_end', '>=', $now->toDateTimeString())->first();
     if (empty($ExternalApiLimit)) {
         $ExternalApiLimit = new ExternalApiLimit();
         $ExternalApiLimit->external_api_name = $externalApiName;
         $ExternalApiLimit->external_api_limit_interval = $externalApiLimitInterval;
         $ExternalApiLimit->external_api_limit = $externalApiLimit;
         $StartEnd = ExternalApiLimit::convertIntervalStringToStartEnd($externalApiLimitInterval, $now);
         $ExternalApiLimit->limit_interval_start = $StartEnd['limit_interval_start'];
         $ExternalApiLimit->limit_interval_end = $StartEnd['limit_interval_end'];
     }
     $ExternalApiLimit->external_api_count = $ExternalApiLimit->external_api_count + 1;
     $ExternalApiLimit->save();
     return $ExternalApiLimit->external_api_limit_left;
 }
开发者ID:Bogstag,项目名称:bogstag.se,代码行数:24,代码来源:Integrator.php

示例5: scopeCompleted

 /**
  * Scope a query to only contain battles that are closed for voting
  */
 public function scopeCompleted($query)
 {
     $votingperiod = config('rap-battle.votingperiod', 24);
     // battles before this date are closed:
     $timeoldest = new Carbon();
     $timeoldest->subHours($votingperiod);
     return $query->where('created_at', '<', $timeoldest->toDateTimeString());
 }
开发者ID:Rap-Battle-App,项目名称:Backend,代码行数:11,代码来源:Battle.php

示例6: setupQuery

 /**
  * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
  */
 protected function setupQuery($query)
 {
     if ($this->start) {
         $query->where('created_at', '>=', $this->start->toDateTimeString());
     }
     if ($this->end) {
         $query->where('created_at', '<=', $this->end->toDateTimeString());
     }
 }
开发者ID:legalweb,项目名称:php-statistics-helper,代码行数:12,代码来源:AbstractEloquentStatisticsProvider.php

示例7: release

 /**
  * Release the job back into the queue.
  *
  * @param  int  $delay
  * @return void
  */
 public function release($delay = 0)
 {
     $now = new Carbon();
     $now->addSeconds($delay);
     $this->job->timestamp = $now->toDateTimeString();
     $this->job->status = Job::STATUS_WAITING;
     $this->job->retries += 1;
     $this->job->save();
     $this->released = true;
 }
开发者ID:brucewu16899,项目名称:laravel-database-queue,代码行数:16,代码来源:DatabaseJob.php

示例8: getTimelineAttribute

 function getTimelineAttribute()
 {
     $date = new Carbon();
     $date->subDays(2);
     $today = Carbon::now();
     // Assignments that need to be completed in 2 days
     $waiting_assignments = DB::table('assignments')->select(DB::raw('id, point, created_at, due_date as date, \'reminder\' as type'))->where('due_date', '>', $date->toDateTimeString())->where('due_date', '>=', $today->toDateTimeString())->whereNotExists(function ($query) {
         $query->select(DB::raw(1))->from('users_assignments')->whereRaw('users_assignments.assignment_id = assignments.id')->where('users_assignments.user_id', '=', $this->id);
     });
     $timeline = DB::table('users_assignments')->select(DB::raw('assignment_id, point, null, created_at as date,  \'assignment\' as type'))->where('user_id', '=', $this->id)->union($waiting_assignments)->orderBy('date', 'desc')->get();
     return $timeline;
 }
开发者ID:nouzun,项目名称:gamification,代码行数:12,代码来源:User.php

示例9: store

 public function store(Requests\PostStoreRequest $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->url = $request->url;
     $post->body = $request->body;
     if ($request->published_at != "") {
         $time = new Carbon($request->published_at);
         $post->published_at = $time->toDateTimeString();
     } else {
         $post->published_at = null;
     }
     $post->save();
     return redirect('/back/posts')->with('status', 'Created Post');
 }
开发者ID:mishavetl,项目名称:dailyblog,代码行数:15,代码来源:PostController.php

示例10: __construct

 /**
  * Create a new Alert instance.
  *
  * @param  string  $msg
  * @param  string  $type
  * @param  string  $datetime
  *
  * @return void
  */
 public function __construct($msg, $type, $datetime = null)
 {
     if (empty($msg) || empty($type)) {
         throw new Exception("Invalid Parameters");
     }
     if (!$this->isValidType($type)) {
         throw new Exception("Invalid alert type");
     }
     $this->id = uniqid();
     $this->message = $msg;
     $this->type = $type;
     if (!is_null($datetime)) {
         $dt = new Carbon($datetime);
         $this->datetime = $dt->toDateTimeString();
     } else {
         $this->datetime = null;
     }
 }
开发者ID:kotfire,项目名称:system-alerts,代码行数:27,代码来源:Alert.php

示例11: update

 public function update(Request $request, $id)
 {
     $session_id = Session::getId();
     if (!$session_id) {
         return response('', 400);
     }
     $this->validate($request, ['id' => 'required|integer']);
     $bookmark = Bookmark::find($id);
     if ($request->bookmark) {
         $bookmark->bookmark = $request->bookmark;
         $bookmark->save();
     }
     if ($request->bookmarked_at) {
         $bookmarked_at = new Carbon($request->bookmarked_at, auth()->user()->timezone);
         $bookmarked_at->setTimezone('UTC');
         $bookmark->bookmarked_at = $bookmarked_at->toDateTimeString();
         $bookmark->save();
     }
     return response('', 204);
 }
开发者ID:gitstashgithub,项目名称:rating,代码行数:20,代码来源:BookmarkController.php

示例12: testRegister

 public function testRegister()
 {
     $birthday = new Carbon();
     $birthday->addYear(-23);
     $this->visit('/auth/register')->type('user1', 'name')->type('user1@case.edu', 'email')->type('useruser', 'password')->type('useruser', 'password_confirmation')->type($birthday->toDateTimeString(), 'bdate')->select('1', 'gender')->type('2000', 'daily_calories');
     $map = [];
     $restrictions = Restriction::all();
     foreach ($restrictions as $restriction) {
         $val = round(mt_rand() / mt_getrandmax());
         $map[$restriction->id] = $val;
         $this->type($val + 1, 'restriction' . ($restriction->id + 1));
     }
     $this->press('Register')->seePageIs('/home');
     $this->seeInDatabase('users', ['name' => 'user1', 'email' => 'user1@case.edu', 'bdate' => $birthday->toDateString(), 'gender' => '0', 'daily_calories' => '2000']);
     $user = \App\User::whereEmail('user1@case.edu')->first();
     foreach ($restrictions as $restriction) {
         if ($map[$restriction->id] == 1) {
             $this->seeInDatabase('restriction_user', ['user_id' => $user->id, 'restriction_id' => $restriction->id]);
         }
     }
 }
开发者ID:lucyktan,项目名称:EECS-393-Nutrition-App,代码行数:21,代码来源:UserAuthTest.php

示例13: checkIsLimitOverByUser

 public function checkIsLimitOverByUser($action, $user, $isFail = null)
 {
     $config = $this->getActionConfig($action);
     if (!isset($config['by_user'])) {
         return;
     }
     $config = $config['by_user'];
     $userId = $user instanceof User ? $user->id : (int) $user;
     $query = DB::table('user_action_log')->select('id')->where('action', $action)->where('user_id', $userId);
     if (isset($config['interval'])) {
         $fromDate = new Carbon();
         $fromDate->subMinutes($config['interval']);
         $query->where('action_date', '>=', $fromDate->toDateTimeString());
     }
     if ($isFail !== null) {
         $isFail = $isFail === true ? BaseModel::TRUE : BaseModel::FALSE;
         $query->where('is_fail', $isFail);
     }
     $maxTriesCount = isset($config['requests_count']) ? $config['requests_count'] : 1;
     $tries = $query->orderBy('id', 'desc')->take($maxTriesCount + 1)->get();
     if (count($tries) > $maxTriesCount) {
         throw new TooMuchRequestException();
     }
 }
开发者ID:practicegeniusci,项目名称:DemoApp,代码行数:24,代码来源:ActionsLog.php

示例14: testGetCompleted

 /**
  * Test for getCompleted
  */
 public function testGetCompleted()
 {
     $user1 = factory(App\Models\User::class)->create();
     $user2 = factory(App\Models\User::class)->create();
     $user3 = factory(App\Models\User::class)->create();
     $user4 = factory(App\Models\User::class)->create();
     $votingperiod = Config::get('rap-battle.votingperiod', 24);
     // battles older than this date are closed:
     $timeoldest = new Carbon();
     $timeoldest->subHours($votingperiod + 1);
     // create two battles
     $battle1 = new Battle();
     $battle1->rapper1_id = $user1->id;
     $battle1->rapper2_id = $user2->id;
     $battle1->video = "/path/to/file";
     $battle1->save();
     $battle2 = new Battle();
     $battle2->rapper1_id = $user3->id;
     $battle2->rapper2_id = $user4->id;
     $battle2->video = "/path/to/file";
     $battle2->created_at = $timeoldest->toDateTimeString();
     $battle2->save();
     $this->get('/battles/completed')->seeJson(['current_page' => 1, 'data' => [['battle_id' => (string) $battle2->id, 'rapper1' => ['user_id' => (string) $user3->id, 'username' => $user3->username, 'profile_picture' => $user3->picture], 'rapper2' => ['user_id' => (string) $user4->id, 'username' => $user4->username, 'profile_picture' => $user4->picture]]]]);
 }
开发者ID:Rap-Battle-App,项目名称:Backend,代码行数:27,代码来源:ControllerBattleTest.php

示例15: __toString

 public function __toString()
 {
     return "サイト復活\n" . $this->time->toDateTimeString() . "\n" . $this->url . "\n";
 }
开发者ID:HiroKws,项目名称:zakkuto-laravel-hub-site,代码行数:4,代码来源:SiteUpped.php


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