日期乱码的解决方案!~

日期乱码的解决方案!~

Dream Vision發表於
Number of replies: 1

曾经在老帖子里面恢复过一位朋友,但是由于大家都不喜欢看老帖子,在贴出来新的,也许对大家有所帮助!~

关于日期的乱码,建议你找找论坛以前的帖子,如果实在没有,用下面的方法试验下,找到lib/moodlelib.php 这个文件,然后找到以下字段:

 function userdate($date, $format='', $timezone=99, $fixday = true) {

            ・・・

            if ($format == '') {
                if (empty($strftimedaydatetime)) {
                    $strftimedaydatetime = get_string('strftimedaydatetime');
                }
                $format = $strftimedaydatetime;
            }
在这里接着添加

$localewincharset = null;
            $textlib = null;


            if (!empty($CFG->unicodedb) && $CFG->ostype == 'WINDOWS') {
                if ($localewincharset = get_string('localewincharset')) {
                    $textlib = textlib_get_instance();
                    $format = $textlib->convert($format, current_charset(), $localewincharset);
                }
            }
到这里

 ・・・

            } else {
                $date += (int)($timezone * 3600);
                if ($fixday) {
                    $datestring = gmstrftime($formatnoday, $date);
                    $daystring  = str_replace(' 0', '', gmstrftime(' %d', $date));
                    $datestring = str_replace('DD', $daystring, $datestring);
                } else {
                    $datestring = gmstrftime($format, $date);
                }
            }

        /// If we are running under Windows and unicode is enabled, try to convert the datestring
        /// to current_charset() (because it's impossible to specify UTF-8 to fetch locale info in Win32)
我做到这里就解决了乱码问题,如果还不行的话继续添加

if ($localewincharset) {
                $datestring = $textlib->convert($datestring, $localewincharset, current_charset());

            }
 return $datestring;
        }
应该是可以的,如果有什么不明白的,可以到我的论坛http://mw.x.sfbbs.net/web.php的软件区去开帖子提问,也可以家我的qq71765163或者msn  xiaohui_22590@homail.com,如果可以为大家解决的,一定尽力!

評比平均分數: -
In reply to Dream Vision

回复: 日期乱码的解决方案!~

Zhigang Sun發表於
此补丁已放入Chinese Moodle中文补丁包的1.7.x_stable_daily_build版,多谢!