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


PHP Carbon::diffInMinutes方法代码示例

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


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

示例1: getProfile

 public function getProfile($userid)
 {
     $user = User::find($userid);
     if (count($user) >= 1) {
         $updated = new Carbon($user->updated_at);
         $now = Carbon::now();
         if ($updated->diff($now)->m < 1) {
             $lastOnline = "Last seen less than a minute ago";
         } elseif ($updated->diff($now)->h < 1) {
             $lastOnline = $updated->diffInMinutes($now) > 1 ? sprintf("Last seen %d minutes ago", $updated->diffInMinutes($now)) : sprintf("Last seen %d minute ago", $updated->diffInMinutes($now));
         } elseif ($updated->diff($now)->d < 1) {
             $lastOnline = $updated->diffInHours($now) > 1 ? sprintf("Last seen %d hours ago", $updated->diffInHours($now)) : sprintf("Last seen %d hour ago", $updated->diffInHours($now));
         } elseif ($updated->diff($now)->d < 7) {
             $lastOnline = $updated->diffInDays($now) > 1 ? sprintf("Last seen %d days ago", $updated->diffInDays($now)) : sprintf("Last seen %d day ago", $updated->diffInDays($now));
         } elseif ($updated->diff($now)->m < 1) {
             $lastOnline = $updated->diffInWeeks($now) > 1 ? sprintf("Last seen %d weeks ago", $updated->diffInWeeks($now)) : sprintf("Last seen %d week ago", $updated->diffInWeeks($now));
         } elseif ($updated->diff($now)->y < 1) {
             $lastOnline = $updated->diffInMonths($now) > 1 ? sprintf("Last seen %d months ago", $updated->diffInMonths($now)) : sprintf("Last seen %d month ago", $updated->diffInMonths($now));
         } else {
             $lastOnline = $updated->diffInYears($now) > 1 ? sprintf("Last seen %d years ago", $updated->diffInYears($now)) : sprintf("Last seen %d year ago", $updated->diffInYears($now));
         }
         return view('dashboard.userProfile', ['user' => $user, 'lastOnline' => $lastOnline]);
     } else {
         return view('dashboard.userProfile');
     }
 }
开发者ID:KarmaLaBelle,项目名称:KaiBanchoo-Web,代码行数:26,代码来源:userProfile.php

示例2: checkStamp

 protected function checkStamp($style, $data)
 {
     switch ($style) {
         case 1:
             $search = \App\Firstcache::where('star', $data['star'])->where('size', $data['size'])->where('class', $data['class'])->where('planet', $data['planet'])->where('step', $data['step'])->first();
             break;
         case 2:
             $search = \App\Secondcache::where('style', $data['style'])->first();
             break;
         case 3:
             $search = \App\Thirdcache::where('star', $data['star'])->where('size', $data['size'])->where('class', $data['class'])->first();
             break;
         case 0:
             $search = \App\Zerocache::where('id', '>', 0)->first();
             break;
     }
     if ($search) {
         $created = new Carbon($search->created_at);
         $now = Carbon::now();
         if ($created->diffInMinutes($now) > 180) {
             $search->delete();
             return false;
         }
         $this->chart = unserialize($search->data);
         return true;
     }
     return false;
 }
开发者ID:Qeenslet,项目名称:elite-lara,代码行数:28,代码来源:Charter.php

示例3: cancelReservation

 public function cancelReservation(User $user, Trip $trip)
 {
     $now = new Carbon();
     $departure = new Carbon($trip->leaves_at);
     $reservation = Booking::where('user_id', $user->id)->where('trip_id', $trip->id)->first();
     $reservationTime = new Carbon($reservation->created_at);
     $percent = $now->diffInMinutes($reservationTime) / $departure->diffInMinutes($reservationTime);
     $karma = round(1 + pow(pow(47, 1 / 3) * $percent, 3));
     $user->karma = $user->karma - $karma;
     $user->save();
 }
开发者ID:pasadinhas,项目名称:sirs-project,代码行数:11,代码来源:KarmaService.php

示例4: destroy

 /**
  * Remove the specified post from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $post = $this->postRepository->find($id);
     if (empty($post)) {
         Flash::error('post no encontrada.');
         return redirect(url('home'));
     }
     $created = new Carbon($post->created_at);
     $transcurrido = $created->diffInMinutes();
     if (Auth::user()->rol != 'admin' && $transcurrido < 120) {
         Flash::warning('Deben pasar 2 horas para poder eliminar el Post han pasado ' . $transcurrido . ' minutos desde la creación');
         return redirect(url('home'));
     }
     $this->postRepository->delete($id);
     if (file_exists($post->imagen)) {
         unlink($post->imagen);
     }
     if (file_exists($post->archivo)) {
         unlink($post->archivo);
     }
     Flash::success('Post borrado satisfactoriamente.');
     return redirect(url('home'));
 }
开发者ID:ProyectoSanClemente,项目名称:proyectoapi5.1,代码行数:30,代码来源:PostController.php

示例5: score

 public static function score(Pirep &$pirep, $rule)
 {
     $pirepStart = new Carbon($pirep->pirep_start_time);
     $offBlocks = new Carbon($pirep->off_blocks_time);
     $length = $pirepStart->diffInMinutes($offBlocks);
     foreach ($rule['thresholds'] as $threshold) {
         // Does the preparation time meet this threshold?
         if ($length >= $threshold['moreThan'] && $length <= $threshold['lessThan']) {
             return ['name' => $threshold['name'], 'points' => $threshold['points']];
         }
     }
     throw new UnsuccessfulScoringException();
 }
开发者ID:aorly,项目名称:vAMSYS,代码行数:13,代码来源:PreparationTime.php

示例6: score

 public static function score(Pirep &$pirep, $rule)
 {
     $flightStart = new Carbon($pirep->departure_time);
     $flightEnd = new Carbon($pirep->landing_time);
     $length = $flightStart->diffInMinutes($flightEnd);
     foreach ($rule['thresholds'] as $threshold) {
         // Does the flight length meet this threshold?
         if ($length >= $threshold['moreThan'] && $length <= $threshold['lessThan']) {
             return ['name' => $threshold['name'], 'points' => $threshold['points']];
         }
     }
     throw new UnsuccessfulScoringException();
 }
开发者ID:aorly,项目名称:vAMSYS,代码行数:13,代码来源:MinuteThresholds.php

示例7: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $dt = Carbon::now('Asia/Colombo');
     $spams = spam::get();
     foreach ($spams as $spam) {
         $dt2 = new Carbon($spam->updated_at, 'Asia/Colombo');
         $val = $dt2->diffInMinutes($dt);
         if ($val > 6) {
             $spam->delete();
         }
     }
     $this->info('spam table cleard!');
 }
开发者ID:dprabhath,项目名称:SEP_WE_016,代码行数:19,代码来源:spams.php

示例8: getNearestPostDuration

 public function getNearestPostDuration($key)
 {
     if ($duration = $this->cache->get($key . '-duration')) {
         return $duration;
     } else {
         $nearest_scheduled_post = $this->post->nearestScheduledPost();
         if (!is_null($nearest_scheduled_post)) {
             $nearest_scheduled_posts_date = new Carbon($nearest_scheduled_post->publish_date, config('app.timezone'));
             $time_difference = $nearest_scheduled_posts_date->diffInMinutes(Carbon::now(config('app.timezone'))) + 1;
             if ($time_difference > 0) {
                 $duration = $this->cache->remember($key . '-duration', function () use($time_difference) {
                     return $time_difference;
                 }, ['posts'], $time_difference);
                 return $duration;
             }
         }
     }
 }
开发者ID:vinelab,项目名称:agency,代码行数:18,代码来源:PostsController.php

示例9: lengthInMinutes

 /**
  * Get the difference between start and end dates of the period in minutes.
  *
  * @return int
  */
 public function lengthInMinutes()
 {
     return $this->startDate->diffInMinutes($this->endDate);
 }
开发者ID:asdf20122012,项目名称:carbon-period,代码行数:9,代码来源:CarbonPeriod.php

示例10: getIntervalMinutes

 private function getIntervalMinutes()
 {
     $dt = new Carbon('today ' . $this->interval);
     $diff_minutes = $dt->diffInMinutes(Carbon::today());
     return $diff_minutes;
 }
开发者ID:sukohi,项目名称:julius,代码行数:6,代码来源:Julius.php

示例11: ageInDays

 public static function ageInDays(Carbon $date) : string
 {
     return number_format(round($date->diffInMinutes() / (24 * 60), 2), 2) . ' (' . $date->diffForHumans() . ')';
 }
开发者ID:spatie,项目名称:laravel-backup,代码行数:4,代码来源:Format.php

示例12: storeSchedule

    public function storeSchedule()
    {
        $input['json'] = '{
						    "user": "3",
						    "event": "1",
						    "time_slots": [
						        {
						            "start": 1411239474,
						            "end": 1411539474,
						            "weighting": "5"
						        },
						        {
						            "start": 1411269474,
						            "end": 1411549474,
						            "weighting": "5"
						        }
						    ]
						}';
        $decoded = json_decode($input['json']);
        $user_id = $decoded->user;
        $occasion_id = $decoded->event;
        // Get the occasion tied to the user
        $occasion = User::find($user_id)->occasions->find($occasion_id);
        if ($occasion == null) {
            return null;
        }
        $time_slots = $decoded->time_slots;
        $insert = array();
        for ($i = 0; $i < count($time_slots); $i++) {
            $start = $time_slots[$i]->start;
            $ts_start = Carbon::createFromTimeStamp($start);
            $end = $time_slots[$i]->end;
            $ts_end = Carbon::createFromTimeStamp($end);
            $insert[] = array('start' => $ts_start->toDateTimeString(), 'end' => $ts_end->toDateTimeString(), 'weighting' => $time_slots[$i]->weighting, 'user_id' => $user_id, 'occasion_id' => $occasion_id);
        }
        //dd($insert);
        Timeslot::insert($insert);
        $occasion->pivot->complete = 1;
        $occasion->pivot->save();
        $num_incomplete_occasions = Occasion::find($occasion_id)->users()->wherePivot('complete', 0)->count();
        if ($num_incomplete_occasions != 0) {
            return $occasion;
        }
        // The events are done - push
        $occasion = Occasion::find($occasion_id);
        $host_start = new Carbon($occasion->start);
        $host_end = new Carbon($occasion->end);
        $diff = $host_start->diffInMinutes($host_end);
        $num_users = $occasion->users->count();
        $score = array();
        $score = array_fill(0, 10000, 0);
        //$score[0] = 'test';
        //$score = 0;
        $k = 0;
        $previous = new Carbon($occasion->start);
        // implement eager loading
        for ($i = 0; $i < $diff; $i += 15) {
            for ($j = 0; $j < $num_users; $j++) {
                $start = new Carbon($occasion->start);
                $start->addMinutes($i);
                $timeslot = Timeslot::where('user_id', '=', $j)->where('start', '<=', $previous->toDateTimeString())->where('end', '>=', $start->toDateTimeString())->first();
                if ($timeslot != null) {
                    //dd($timeslot);
                    //$score = array_add($score, $i, $timeslot->weighting);
                    $score[$i] += $timeslot->weighting;
                    //$score[$i] += $timeslot->weighting;
                    //$score[] = array($timeslot->weighting);
                    //$k++;
                    //var_dump($score);
                }
            }
            $previous = $start;
        }
        $score = array_filter($score);
        //dd($score);
        rsort($score);
        $top3 = array_reverse(array_slice($score, 0, 3));
        $users = Occasion::find($occasion_id)->users()->get();
        $data = array('temp');
        $users = $users->each(function ($user) use($data) {
            \Mail::send('emails.invite', $data, function ($message) use($user) {
                $message->to($user->email, $user->name)->subject('Your event has been scheduled!');
            });
            \Twilio::message($user->phone, 'An event has finished scheduling! Open up Calendr to learn more.');
        });
        $app_id = 'jVmr9Q4ItzKs2abze4T2mRvECJ8AxMwCKT5G8anC';
        $rest_key = 'hNv7GwawFKdvpyb6B6u8sLqlSQMW3YWWRQeKVll7';
        $master_key = 'wzwEOPsb5w45qWQQVJSCqTtL6yvD82Y90SiVDh4y';
        ParseClient::initialize($app_id, $rest_key, $master_key);
        $data = array("alert" => "An event has finished scheduling! Press here to learn more.");
        ParsePush::send(array("channels" => ["PHPFans"], "data" => $data));
        $query = ParseInstallation::query();
        $query->equalTo("design", "rad");
        ParsePush::send(array("where" => $query, "data" => $data));
        //	dd($score);
    }
开发者ID:seeARMS,项目名称:HackTheNorth_API,代码行数:96,代码来源:Algorithm.php

示例13: getMinDiff

 private function getMinDiff(Carbon $time1, Carbon $time2)
 {
     if ($time2->lt($time1)) {
         // if timeout is less than breakout
         $time2->addDay();
     }
     // add 1 day
     return $time2->diffInMinutes($time1);
 }
开发者ID:jrsalunga,项目名称:gi-manager,代码行数:9,代码来源:DtrController.php


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