/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $lasts = Last::all(); foreach ($lasts as $key) { $created = new \Carbon\Carbon($key->date); $now = \Carbon\Carbon::now(); $difference = $created->diffInDays($now); $key['dateWords'] = $created->format('l, F jS, Y'); $key['datediff'] = $difference; } return view('welcome.index', ['lasts' => $lasts]); }
/** * Execute the console command. * * @return mixed */ public function handle() { $lasts = Last::all(); foreach ($lasts as $key) { $created = new \Carbon\Carbon($key->date); $now = \Carbon\Carbon::now(); $difference = $created->diffInDays($now); $key['dateWords'] = $created->format('l, F jS, Y'); $key['datediff'] = $difference; } $now = \Carbon\Carbon::now(); foreach ($lasts as $l) { if ($now > $l->lastNotify) { Mail::send('email.daysago', ['l' => $l], function ($m) { $m->from('*****@*****.**', 'The last time @samyerkes...'); $m->to('*****@*****.**', 'samyerkes')->subject('Keep going...'); }); unset($l->dateWords, $l->datediff); $l->lastNotify = \Carbon\Carbon::now()->addDays($l->notifyInteger); $l->save(); } } echo 'emails sent'; }
protected function _getBiggestGap($timeSeries) { $lastHourlyData = null; $maxDifference = 0; foreach ($timeSeries as $hourlyData) { if ($lastHourlyData) { $lastTime = new \Carbon\Carbon($lastHourlyData['time']); $thisTime = new \Carbon\Carbon($hourlyData['time']); if ($thisTime->diffInDays(\Carbon\Carbon::now()) > 30) { break; } $difference = $thisTime->diffInHours($lastTime); $maxDifference = max($difference, $maxDifference); } $lastHourlyData = $hourlyData; } return $maxDifference; }
// 'day': 30, // 'month': 9, // 'year': 2015, // 'hour': 0, // 'min': 0, // 'sec': 0 // }, // omitWeeks: true <?php $launchingDateTime = !empty($global_params['launching_datetime']) ? $global_params['launching_datetime'] : '2017-01-01 00:00:00'; $datetime = new Carbon\Carbon($launchingDateTime); $sec = $datetime->diffInSeconds() % 60; $min = $datetime->diffInMinutes() % 60; $hour = $datetime->diffInHours() % 24; $day = $datetime->diffInDays() % 30; $month = $datetime->diffInMonths() % 12; $year = $datetime->diffInYears(); ?> targetOffset: { 'day': {{ $day }}, 'month': {{ $month }}, 'year': {{ $year }}, 'hour': {{ $hour }}, 'min': {{ $min }}, 'sec': {{ $sec }} }, omitWeeks: true });