/** * Get the time difference in a human readable format. * * @param \Carbon\Carbon|\TimeDate $other * @param bool $absolute Removes time difference modifiers ago, after, etc * * @return string The time as a human readable string */ public function diffForHumans(Carbon\Carbon $other = null, $absolute = false) { if (self::diffInSeconds($other, true) < 4) { return "now"; } return parent::diffForHumans($other, $absolute); }
$sSinceClass = "day_plus"; $sSinceText = "> 1 day"; } if ($iSecondsSinceUpdated < 14400) { $sSinceClass = "day"; $sSinceText = "< 1 day"; } if ($iSecondsSinceUpdated < 3600) { $sSinceClass = "recent"; $sSinceText = "< 1 hr"; } if ($iSecondsSinceUpdated < 900) { $sSinceClass = "active"; $sSinceText = "< 15 mins"; } $sLastHit = $oLastHit->diffForHumans(); } ?> <td title="{{--$oLastHit->toDayDateTimeString()--}}">{{$sLastHit}}</td> <td> <span class="label pulled-since {{$sSinceClass}}">{{$sSinceText}}</span></td> <td>{{$oUserFeed->feed->item_count}}</td> <td><a target="_blank" href="/pullallfeeds/{{$oUserFeed->feed_id}}">pull now</a></td> <td><a href="/feeds/{{$oUserFeed->id}}">edit</a></td> <td> <form action="/feeds/{{$oUserFeed->id}}" method="post" onsubmit="return confirm('you sure?');"> <input type="hidden" name="_method" value="DELETE"> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="submit" value="delete"> </form> </td>
$pPrice = $pId->pSellingPrice; $pQun = $qry->pQuantity; echo '$' . $pPrice * $pQun; ?> </td> </tr> <tr> <td>Date of Purchase</td> <td> <?php $databaseDate = new Carbon\Carbon($qry->bDate); //echo $databaseDate->diffForHumans(); echo $databaseDate->diffForHumans(); ?> </td> </tr> </tbody> </table> </div>
public function getHumanCreatedAtAttribute($date) { $date = new \Carbon\Carbon($this->created_at); // Now modify and return the date return $date->diffForHumans(); }