【问题标题】:Get date from Carbon function Laravel 5从 Carbon 函数 Laravel 5 获取日期
【发布时间】:2015-09-28 23:48:17
【问题描述】:

我使用 Laravel5 Carbon 功能:

$carbon_today=碳::today();

在 dd($carbon_today) 之后得到这个:

Carbon {#200 ▼
  +"date": "2015-07-10 00:00:00"
  +"timezone_type": 3
  +"timezone": "UTC"
}

这很好。现在我只需要使用来自 CArbon 的日期来输入变量。试试 foreach,

foreach ($carbon_today as $row) {
    $x= $row['date'];
  dd($x);
}

没有成功

【问题讨论】:

  • $carbon_today= Carbon::today()->format('Y-m-d G:H:i');解决问题! Tnx!

标签: php laravel laravel-5 foreach php-carbon


【解决方案1】:

试试

$today = Carbon::today();;
echo $today;

$today = Carbon::today()->toDateTimeString();
echo $today;

Read More

【讨论】:

    【解决方案2】:

    你不需要循环使用它就像使用它一样

    $carbon_today= Carbon::today();
    return $carbon_today;
    

    您将在 $carbon_today 变量中获得今天的日期

    【讨论】:

      猜你喜欢
      • 2017-07-06
      • 1970-01-01
      • 2019-06-18
      • 2017-04-28
      • 1970-01-01
      • 2016-12-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-19
      相关资源
      最近更新 更多