Skip to content

Instantly share code, notes, and snippets.

@nullproduction
Created May 4, 2015 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nullproduction/3c9a87c4ba71d6eda43f to your computer and use it in GitHub Desktop.
Save nullproduction/3c9a87c4ba71d6eda43f to your computer and use it in GitHub Desktop.
Example
<?php namespace App\Libs\Helper;
use Jenssegers\Date\Date;
class Helper {
/**
* Get Date
*/
public static function getDate($date)
{
$twoDaysSeconds = 60 * 60 * 24 * 2;
$seconds = time() - Date::parse($date)->timestamp;
if ($seconds == 0) return 'Сейчас';
return ($seconds < $twoDaysSeconds) ?
Date::parse($date)->ago() :
Date::parse($date)->format("j M в H:i");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment