Skip to content

Instantly share code, notes, and snippets.

@mostafa6765
Last active September 19, 2017 14:54
Show Gist options
  • Save mostafa6765/be5c067852b5cb4102e45c2622f4ce89 to your computer and use it in GitHub Desktop.
Save mostafa6765/be5c067852b5cb4102e45c2622f4ce89 to your computer and use it in GitHub Desktop.
@foreach ($users as $key => $me)
@if ( Date::parse($me->created_at)->format('l j F Y ')==Date::parse('now')->format('l j F Y ') )
<p>{{ Date::parse($me->created_at)->ago() }}</p>
@else
<p>{{ Date::parse($me->created_at)->format('l j F Y H:i:s') }}</p>
@endif
@endforeach
<? php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Jenssegers\Date\Date;
class DateController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
Date::setLocale('en');
$users = User::paginate(10);
return view('paginate')->withUsers($users);
}
}
@foreach ($users as $key => $me)
@if ($me->created_at->diffForHumans()<=12)
<p>{{ Date::parse($me->created_at)->ago() }}</p>
@else
<p>{{ Date::parse($me->created_at)->format('l j F Y H:i:s') }}</p>
@endif
@endforeach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment