【问题标题】:How to Format a Carbon Date to get the Full Month如何格式化碳日期以获得整月
【发布时间】:2016-07-05 16:33:48
【问题描述】:

我正在使用此代码:

 Carbon\Carbon::parse($quotation[0]->created_at)->format('d M Y')

输出是:

2016 年 3 月 10 日

我想要:

2016 年 3 月 10 日

我查看了 Carbon 文档并在谷歌上搜索过,但我在任何地方都找不到。

【问题讨论】:

    标签: php-carbon


    【解决方案1】:

    如果我理解正确的话:

     Carbon\Carbon::parse($quotation[0]->created_at)->format('d F Y')
    

    顺便说一句,我在 php date docs 中找到了它,Carbon 使用它来生成日期。 https://www.php.net/manual/function.date

    【讨论】:

      【解决方案2】:

      如果您希望在日期中包含完整的月份名称,应该这样使用它:

      {{\Carbon\Carbon::parse($client[0]->event_date_from)->format('d F Y')}}
      

      format 函数中使用 f 而不是 M

      【讨论】:

        【解决方案3】:
        $date1 = '2020-03-05'; 
        
        $date2 = Carbon::parse($date1)->format('d F y');
        
        dd($date2);
        

        【讨论】:

          【解决方案4】:
            <span class="text-muted">{{$item->created_at->format('F,d,Y')}}</span>
          

          【讨论】:

            猜你喜欢
            • 2020-02-07
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2011-05-23
            • 2018-03-16
            • 2018-08-06
            • 2011-10-26
            相关资源
            最近更新 更多