Правильно говорят, надо всего-то одну функцию поменять и будет вам счастье, где хотите. Вот мой вариант, причём на главной странице нормальное время показывающий и время коверкающий, только если запрошен стандартный формат ($board_config['default_dateformat']).
Источник вдохновления:
##############################################################
## MOD Title: Today At/Yesterday At
## MOD Author: netclectic <
adrian@netclectic.com > (Adrian Cockburn)
http://www.netclectic.com
## MOD Description: Will show Today At if the post was posted today
## Will show Yesterday At if the post was posted yesterday
##
## MOD Version: 1.3.1
Код: Выделить всё
Index: language/lang_russian/lang_main.php
===================================================================
--- language/lang_russian/lang_main.php (revision 166)
+++ language/lang_russian/lang_main.php (working copy)
@@ -1070,6 +1070,9 @@
$lang['Album'] = 'Альбом';
$lang['Personal_Gallery_Of_User'] = 'Персональная галерея пользователя %s';
+$lang['Today_at'] = '<b>Сегодня</b> в';
+$lang['Yesterday_at'] = '<b>Вчера</b> в';
+
//
// That's all Folks!
// -------------------------------------------------
Index: includes/page_header.php
===================================================================
--- includes/page_header.php (revision 166)
+++ includes/page_header.php (working copy)
@@ -368,7 +368,7 @@
'SITE_DESCRIPTION' => $board_config['site_desc'],
'PAGE_TITLE' => $page_title,
'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit),
- 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
+ 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date_simple($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
'TOTAL_USERS_ONLINE' => $l_online_users,
'LOGGED_IN_USER_LIST' => $online_userlist,
'RECORD_USERS' => sprintf($lang['Record_online_users'], $board_config['record_online_users'], create_date($board_config['default_dateformat'], $board_config['record_online_date'], $board_config['board_timezone'])),
Index: includes/functions.php
===================================================================
--- includes/functions.php (revision 166)
+++ includes/functions.php (working copy)
@@ -392,7 +392,7 @@
//
// Create date/time from format and timezone
//
-function create_date($format, $gmepoch, $tz)
+function create_date_simple($format, $gmepoch, $tz)
{
global $board_config, $lang;
static $translate;
@@ -410,6 +410,33 @@
}
//
+// Create date/time from format and timezone
+//
+function create_date($format, $gmepoch, $tz)
+{
+ global $board_config, $lang;
+
+ if ( $board_config['default_dateformat'] === $format )
+ {
+ $today_ary = explode('|', create_date_simple('m|d|Y', time(), $tz));
+ $board_config['time_today'] = gmmktime(0 - $tz - $board_config['dstime'], 0, 0, $today_ary[0], $today_ary[1], $today_ary[2]);
+ $board_config['time_yesterday'] = $board_config['time_today'] - 86400;
+ unset($today_ary);
+ if ( $board_config['time_today'] < $gmepoch )
+ {
+ return $lang['Today_at'] . ' ' . create_date_simple($board_config['default_timeformat'], $gmepoch, $tz);
+ }
+ else if ( $board_config['time_yesterday'] < $gmepoch)
+ {
+ return $lang['Yesterday_at'] . ' ' . create_date_simple($board_config['default_timeformat'], $gmepoch, $tz);
+ }
+ }
+
+ return create_date_simple($format, $gmepoch, $tz);
+
+}
+
+//
// Pagination routine, generates
// page number sequence
//
Index: common.php
===================================================================
--- common.php (revision 166)
+++ common.php (working copy)
@@ -224,6 +224,12 @@
$board_config[$row['config_name']] = $row['config_value'];
}
+$time_reg = '([gh][[:punct:][:space:]]{1,2}[i][[:punct:][:space:]]{0,2}[a]?[[:punct:][:space:]]{0,2}[s]?)';
+eregi($time_reg, $board_config['default_dateformat'], $regs);
+$board_config['default_timeformat'] = $regs[1];
+unset($time_reg);
+unset($regs);
+
include($phpbb_root_path . 'attach_mod/attachment_mod.'.$phpEx);
if (file_exists('install') || file_exists('contrib'))
Добавлено спустя 1 час 23 минуты 12 секунд:
Меня только смущает вот это. А если я захочу
i:H ?
Код: Выделить всё
$time_reg = '([gh][[:punct:][:space:]]{1,2}[i][[:punct:][:space:]]{0,2}[a]?[[:punct:][:space:]]{0,2}[s]?)';
Добавлено спустя 11 минут 35 секунд:
А чтоб настройки юзверя учитывались, то ещё и так:
Код: Выделить всё
--- includes/functions.php (revision 167)
+++ includes/functions.php (working copy)
@@ -262,6 +262,11 @@
if ( !empty($userdata['user_dateformat']) )
{
$board_config['default_dateformat'] = $userdata['user_dateformat'];
+ $time_reg = '([gh][[:punct:][:space:]]{1,2}[i][[:punct:][:space:]]{0,2}[a]?[[:punct:][:space:]]{0,2}[s]?)';
+ eregi($time_reg, $board_config['default_dateformat'], $regs);
+ $board_config['default_timeformat'] = $regs[1];
+ unset($time_reg);
+ unset($regs);
}
if ( isset($userdata['user_timezone']) )