【问题标题】:Subtract Time on Laravel Views在 Laravel 视图上减去时间
【发布时间】:2014-11-30 11:32:44
【问题描述】:

这是我的代码

    @foreach($myquery as $mydate)
    <tr>
        <td>{{date('l',strtotime($mydate->logon))}}</td>
        <td>{{date('jS F, Y',strtotime($mydate->logon))}}</td>
        <td>{{date('h:i A',strtotime($mydate->logon))}}</td>
        <td>{{date('h:i A',strtotime($mydate->logoff))}}</td>
        <td>{{$mydate->logon->diff($mydate->logoff)}}</td>
    </tr>
    @endforeach

我想要做的是获得登录和注销的区别。我只是收到此代码的错误 500,请帮助

【问题讨论】:

  • 请转到您的app/config/app.php 并将debug 更改为true 并使用实际的错误消息更新您的问题。
  • 它已经设置为真先生
  • 那么错误信息是什么?没有它就很难知道发生了什么。
  • 抱歉,这就是我刚刚得到的 呃-哦,出了点问题!错误代码:500
  • 我找到了答案,在这种情况下,数据库中的 mydate 尚未转换为字符串,我会回答我的问题

标签: php mysql laravel views strtotime


【解决方案1】:

我的错,我忘记了日期还没有转换为字符串来减去它

    @foreach($myquery as $mydate)
    <tr>
        <td>{{date('l',strtotime($mydate->logon))}}</td>
        <td>{{date('jS F, Y',strtotime($mydate->logon))}}</td>
        <td>{{$date1=date('h:i A',strtotime($mydate->logon))}}</td>
        <td>{{$date2=date('h:i A',strtotime($mydate->logoff))}}</td>
        <td>{{$date2-$date1}}</td>
    </tr>
    @endforeach

【讨论】:

  • 又出问题了,我得到了否定结果
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-24
  • 1970-01-01
相关资源
最近更新 更多