dongyan3018 2017-12-27 20:05
浏览 309
已采纳

在laravel字段中显示时间戳的日期部分

I have a table data value in my laravel blade:

<td>{{$events->updated_at}}</td>

which just reads from a database timestamp value. It works and displays as it should but the controller is reading the full timestamp, which we need, but in this table data cell I only want to display the date portion.

So instead of 2017-12-27-00:00:00, I just want to show 2017-12-27.

Is there a special way I should go about this in a laravel blade?

  • 写回答

3条回答 默认 最新

  • dqayok7935 2017-12-27 20:08
    关注

    All the timestamps in an Eloquent object use the Carbon class, making formatting easier. So all you have to do is use the Carbon format functions:

    <td>{{$events->updated_at->toDateString()}}</td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架