示例#1
4
 public function PublishedAt()
 {
     $carbon = new Carbon($this->created_at);
     return $carbon->toFormattedDateString();
 }
 public function index()
 {
     $timestamps = Order::where('created_at', '>=', Carbon::today()->startOfMonth())->lists('created_at');
     foreach ($timestamps as $key => $timestamp) {
         $format = new Carbon($timestamp);
         $timestamps[$key] = $format->toFormattedDateString();
     }
     $totals = Order::where('created_at', '>=', Carbon::today()->startOfMonth())->lists('amount');
     foreach ($totals as $key => $value) {
         $totals[$key] = round($value, 0, PHP_ROUND_HALF_EVEN);
     }
     $total = 0;
     foreach ($totals as $val) {
         $total += $val;
     }
     return view('admin.dashboard', compact('timestamps', 'totals', 'total'));
 }
示例#3
0
use Carbon\Carbon;
use Citco\Carbon as CitcoCarbon;
use CarbonExt\FiscalYear\Calculator;
// Object Instantiation
$brisbane = new Carbon('2015-12-01', 'Australia/Brisbane');
$newYorkCity = new Carbon('2015-12-01', 'America/New_York');
$dtBerlin = new Carbon('2015-12-01', 'Europe/Berlin');
$outputString = "Time difference between %s & %s: %s hours.\n";
// Date difference
printf($outputString, "Berlin", "Brisbane, Australia", $dtBerlin->diffInHours($brisbane, false));
printf($outputString, "Berlin", "New York City, America", $dtBerlin->diffInHours($newYorkCity, false));
$septEighteen2014 = Carbon::createFromDate(2014, 9, 18, $dtBerlin->getTimezone());
printf("difference between now and %s in \n\thours: %d, \n\tdays: %d, \n\tweeks: %d, \n\tweekend days: %d, \n\tweek days: %s, \n\thuman readable: %s\n", $septEighteen2014->toFormattedDateString(), $dtBerlin->diffInHours($septEighteen2014), $dtBerlin->diffInDays($septEighteen2014), $dtBerlin->diffInWeeks($septEighteen2014), $dtBerlin->diffInWeekendDays($septEighteen2014), $dtBerlin->diffInWeekDays($septEighteen2014), $dtBerlin->diffForHumans($septEighteen2014));
// Date formatting
echo $dtBerlin->toDateString() . "\n";
echo $dtBerlin->toFormattedDateString() . "\n";
echo $dtBerlin->toTimeString() . "\n";
echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no");
printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no");
printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no");
printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no");
示例#4
0
 public function getStartDateAttribute($value)
 {
     $carbon = new Carbon($value);
     return $carbon->toFormattedDateString();
 }
示例#5
-1
 public static function date(Carbon $date)
 {
     if ($date->diffInDays(Carbon::now()) < 7) {
         return $date->diffForHumans();
     } else {
         return $date->toFormattedDateString();
     }
 }
示例#6
-13
 public function getLastPlayedAttribute($value)
 {
     $date = new Carbon($value);
     return $date->toFormattedDateString();
 }