|
@ -19,9 +19,11 @@ |
|
|
class Format |
|
|
class Format |
|
|
{ |
|
|
{ |
|
|
/* Date & time */ |
|
|
/* Date & time */ |
|
|
static protected $time_format = 'H:i:s'; |
|
|
|
|
|
static protected $date_format = 'd.m.Y'; |
|
|
|
|
|
static protected $date_time_format = 'H:i d.m.Y'; |
|
|
|
|
|
|
|
|
static protected $time_format = 'H:i:s'; |
|
|
|
|
|
static protected $date_format = 'd.m.Y'; |
|
|
|
|
|
static protected $today_format = 'Сегодня'; |
|
|
|
|
|
static protected $date_time_format = 'H:i d.m.Y'; |
|
|
|
|
|
static protected $today_time_format = 'H:i Сегодня'; |
|
|
static protected $timezone_offset = 0; |
|
|
static protected $timezone_offset = 0; |
|
|
|
|
|
|
|
|
/* money */ |
|
|
/* money */ |
|
@ -71,8 +73,8 @@ class Format |
|
|
$minutes = floor(($timestamp / 60) - ($hours * 60)); |
|
|
$minutes = floor(($timestamp / 60) - ($hours * 60)); |
|
|
$seconds = $timestamp - ($hours * 3600) - ($minutes * 60); |
|
|
$seconds = $timestamp - ($hours * 3600) - ($minutes * 60); |
|
|
|
|
|
|
|
|
return ($hours < 10 ? ('0' . $hours) : $hours) |
|
|
|
|
|
. ':' . ($minutes < 10 ? ('0' . $minutes) : $minutes) |
|
|
|
|
|
|
|
|
return ($hours < 10 ? ('0' . $hours) : $hours) |
|
|
|
|
|
. ':' . ($minutes < 10 ? ('0' . $minutes) : $minutes) |
|
|
. ':' . ($seconds < 10 ? ('0' . $seconds) : $seconds); |
|
|
. ':' . ($seconds < 10 ? ('0' . $seconds) : $seconds); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -85,15 +87,18 @@ class Format |
|
|
*/ |
|
|
*/ |
|
|
static public function int2date($timestamp = 0, $hours = true) |
|
|
static public function int2date($timestamp = 0, $hours = true) |
|
|
{ |
|
|
{ |
|
|
$date = date(($hours) ? self::$date_time_format : self::$date_format , $timestamp); |
|
|
|
|
|
return $date; |
|
|
|
|
|
|
|
|
if (date('Ymd') == date('Ymd', $timestamp)) { |
|
|
|
|
|
return date(($hours) ? self::$today_time_format : self::$today_format , $timestamp); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return date(($hours) ? self::$date_time_format : self::$date_format , $timestamp); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static public function int2rusDate($timestamp = 0, $hours = false) |
|
|
static public function int2rusDate($timestamp = 0, $hours = false) |
|
|
{ |
|
|
{ |
|
|
$month = array('января', 'февраля', 'марта', |
|
|
|
|
|
'апреля', 'мая', 'июня', |
|
|
|
|
|
'июля', 'августа', 'сентября', |
|
|
|
|
|
|
|
|
$month = array('января', 'февраля', 'марта', |
|
|
|
|
|
'апреля', 'мая', 'июня', |
|
|
|
|
|
'июля', 'августа', 'сентября', |
|
|
'октября', 'ноября', 'декабря'); |
|
|
'октября', 'ноября', 'декабря'); |
|
|
$date = ($hours) ? date('H:i d', $timestamp) . ' ' . $month[date('m', $timestamp) - 1] . ' ' .date('Y', $timestamp) : date('d', $timestamp) . ' ' . $month[date('m', $timestamp) - 1] . ' ' .date('Y', $timestamp); |
|
|
$date = ($hours) ? date('H:i d', $timestamp) . ' ' . $month[date('m', $timestamp) - 1] . ' ' .date('Y', $timestamp) : date('d', $timestamp) . ' ' . $month[date('m', $timestamp) - 1] . ' ' .date('Y', $timestamp); |
|
|
return $date; |
|
|
return $date; |
|
@ -110,6 +115,18 @@ class Format |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
* Установка форматов даты |
|
|
|
|
|
* |
|
|
|
|
|
*/ |
|
|
|
|
|
static public function setDateTimeFormat($date_time_format, $today_time_format = false) |
|
|
|
|
|
{ |
|
|
|
|
|
self::$date_time_format = $date_time_format; |
|
|
|
|
|
if ($today_time_format) { |
|
|
|
|
|
self::$today_time_format = $today_time_format; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
* Преобразует время в секунды. |
|
|
* Преобразует время в секунды. |
|
|
* |
|
|
* |
|
|
* @param string $time |
|
|
* @param string $time |
|
|