Skip to content

Instantly share code, notes, and snippets.

@kolyadin
Created February 19, 2014 14:02
Show Gist options
  • Save kolyadin/9092679 to your computer and use it in GitHub Desktop.
Save kolyadin/9092679 to your computer and use it in GitHub Desktop.
$timestamp = func_get_args()[0];
$month = explode(' ', 'января февраля марта апреля мая июня июля августа сентября октября ноября декабря');
if ((time() - $timestamp) < 60 * 60 * 24) {
$out = 'сегодня, ';
} elseif ((time() - $timestamp) > 60 * 60 * 24 && (time() - $timestamp) < 60 * 60 * 24 * 2) {
$out = 'вчера, ';
} else {
$out = sprintf('%u %s %04u, ',
date('d', $timestamp),
$month[date('m', $timestamp) + 1],
date('Y', $timestamp)
);
}
$out .= date('H:i', $timestamp);
return $out;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment