• <small id='3PRje'></small><noframes id='3PRje'>

    <legend id='3PRje'><style id='3PRje'><dir id='3PRje'><q id='3PRje'></q></dir></style></legend>
    <i id='3PRje'><tr id='3PRje'><dt id='3PRje'><q id='3PRje'><span id='3PRje'><b id='3PRje'><form id='3PRje'><ins id='3PRje'></ins><ul id='3PRje'></ul><sub id='3PRje'></sub></form><legend id='3PRje'></legend><bdo id='3PRje'><pre id='3PRje'><center id='3PRje'></center></pre></bdo></b><th id='3PRje'></th></span></q></dt></tr></i><div id='3PRje'><tfoot id='3PRje'></tfoot><dl id='3PRje'><fieldset id='3PRje'></fieldset></dl></div>

      <tfoot id='3PRje'></tfoot>

        • <bdo id='3PRje'></bdo><ul id='3PRje'></ul>
      1. 在 Views laravel 上使用 carbon

        时间:2023-09-24

        <small id='OxQk8'></small><noframes id='OxQk8'>

        <i id='OxQk8'><tr id='OxQk8'><dt id='OxQk8'><q id='OxQk8'><span id='OxQk8'><b id='OxQk8'><form id='OxQk8'><ins id='OxQk8'></ins><ul id='OxQk8'></ul><sub id='OxQk8'></sub></form><legend id='OxQk8'></legend><bdo id='OxQk8'><pre id='OxQk8'><center id='OxQk8'></center></pre></bdo></b><th id='OxQk8'></th></span></q></dt></tr></i><div id='OxQk8'><tfoot id='OxQk8'></tfoot><dl id='OxQk8'><fieldset id='OxQk8'></fieldset></dl></div>

          <tbody id='OxQk8'></tbody>
        • <tfoot id='OxQk8'></tfoot>

              <legend id='OxQk8'><style id='OxQk8'><dir id='OxQk8'><q id='OxQk8'></q></dir></style></legend>
              • <bdo id='OxQk8'></bdo><ul id='OxQk8'></ul>

                  本文介绍了在 Views laravel 上使用 carbon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想在视图上使用 Carbon,我将它包含在视图文件的顶部,但它不起作用,我就是这样做的.

                  I want to use the Carbon on Views I'm including it on the top of the views file but it doesnt work, I'm doing it like this.

                   <?php use carbon/carbon;?>
                   @extends('main_layout')
                  
                        @foreach ($myquery as $mytask) 
                                  <tr>
                  
                                  <td >
                                   {{($mytask->firstname)}}
                                  </td>
                  
                                   <td >
                                          {{($mytask->lastname)}}
                                  </td>
                                      <td>
                                 {{($mytask->logon)}}
                                      </td>
                  
                   @section('content')
                   @stop
                  

                  我只是遇到错误.我想使用 carbon 将 {{($mytask->logon)}} 转换为人类可读的格式

                  I just get errors. I want to convert the {{($mytask->logon)}} to human readable format using carbon

                  推荐答案

                  EDIT 2021-10-29

                  看来 Laravel 现在鼓励使用这个问题的日期转换:

                  It appears that Laravel now encourages the use of date casts for this question:

                  /**
                   * The attributes that should be cast.
                   *
                   * @var array
                   */
                  protected $casts = [
                      'created_at' => 'datetime:Y-m-d',
                  ];
                  

                  原答案

                  我会添加一些引用 Laravel 文档 的内容,供 googlers 添加可以将您的 SQL 日期时间字段转换为 Carbon 对象:

                  I would add sommething quoting Laravel Documentation for googlers to add how you can transform your SQL datetime fields into Carbon objects:

                  在您的模型中:

                  protected $dates = ['created_at', 'updated_at', 'disabled_at','mydate'];
                  

                  这个数组上的所有字段都可以在你的视图中使用 Carbon 函数自动访问,例如:

                  All the fields present on this array will be automatically accessible in your views with Carbon functions like:

                  {{ $article->mydate->diffForHumans() }}
                  

                  这篇关于在 Views laravel 上使用 carbon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Laravel Eloquent 关系的限制结果 下一篇:Laravel Eloquent::Find() 使用现有 ID 返回 NULL

                  相关文章

                  最新文章

                    <tfoot id='NvcOw'></tfoot>

                    <small id='NvcOw'></small><noframes id='NvcOw'>

                    1. <i id='NvcOw'><tr id='NvcOw'><dt id='NvcOw'><q id='NvcOw'><span id='NvcOw'><b id='NvcOw'><form id='NvcOw'><ins id='NvcOw'></ins><ul id='NvcOw'></ul><sub id='NvcOw'></sub></form><legend id='NvcOw'></legend><bdo id='NvcOw'><pre id='NvcOw'><center id='NvcOw'></center></pre></bdo></b><th id='NvcOw'></th></span></q></dt></tr></i><div id='NvcOw'><tfoot id='NvcOw'></tfoot><dl id='NvcOw'><fieldset id='NvcOw'></fieldset></dl></div>
                    2. <legend id='NvcOw'><style id='NvcOw'><dir id='NvcOw'><q id='NvcOw'></q></dir></style></legend>
                      • <bdo id='NvcOw'></bdo><ul id='NvcOw'></ul>