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


PHP Carbon::toFormattedDateString方法代码示例

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


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

示例1: PublishedAt

 public function PublishedAt()
 {
     $carbon = new Carbon($this->created_at);
     return $carbon->toFormattedDateString();
 }
开发者ID:jamesddube,项目名称:blog,代码行数:5,代码来源:Article.php

示例2: index

 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'));
 }
开发者ID:omasterdesign,项目名称:omasterdefault,代码行数:17,代码来源:AdminController.php

示例3: Carbon

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");
开发者ID:settermjd,项目名称:carbon-experiments,代码行数:31,代码来源:index.php

示例4: getStartDateAttribute

 public function getStartDateAttribute($value)
 {
     $carbon = new Carbon($value);
     return $carbon->toFormattedDateString();
 }
开发者ID:Kizlo,项目名称:cvSandbox,代码行数:5,代码来源:Experience.php

示例5: date

 public static function date(Carbon $date)
 {
     if ($date->diffInDays(Carbon::now()) < 7) {
         return $date->diffForHumans();
     } else {
         return $date->toFormattedDateString();
     }
 }
开发者ID:undownding,项目名称:cnBeta1,代码行数:8,代码来源:String.php

示例6: getLastPlayedAttribute

 public function getLastPlayedAttribute($value)
 {
     $date = new Carbon($value);
     return $date->toFormattedDateString();
 }
开发者ID:GMSteuart,项目名称:PandaLove,代码行数:5,代码来源:Character.php


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