邪罗刹的菠萝阁


> 嘿嘿,来小邪这里就一定要淡定。因为,那个,貌似,小邪又忍不住弄了一大段代码在下边 >.<。
> 这篇文章主要通过修改 WordPress 函数来修正时间,以及一部分 Linux 服务器常用命令说明。

一. WordPress的Linux-VPS时间校正:

> 在 WP 后台设置显示的是 “UTC 时间是2010-07-07 8:03:59 本地时间为 2010-07-08 4:03:59”。
> 而实际上现在小邪的电脑上的时间现在是 2010-07-07 20:03:59,瞬间小邪就震精了,额滴神。

-bash-3.2# date
// "-bash-3.2#" 是命令提示,就像 Win 下面的 "C:\Documents and Settings\Administrator>" 一样
// date 是显示当前服务器时间的函数
Thu Jul  8 04:03:59 CST 2010

> 而且在 WordPress 的后台选择的时区是上海,这个是木有错的。但是在数据库里面乱套了。
> 数据库里的 GMT 时间却是北京时间,正常时间却是美国时间,然后经过设置纠正,就诡异鸟。

> 大家应该看出有多么杯具了。~(>_<)~,突然有种想吞鼠标的冲动,大家不要拦着小邪 ( ⊙o⊙ )。

function get_comment_time( $d = '', $gmt = false, $translate = true ) {
	global $comment;
	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date_gmt;
	if ( '' == $d )
		$date = mysql2date(get_option('time_format'), $comment_date, $translate);
	else
		$date = mysql2date($d, $comment_date, $translate);
	return apply_filters('get_comment_time', $date, $d, $gmt, $translate);
}
function get_comment_date( $d = '' ) {
	global $comment;
	if ( '' == $d )
		$date = mysql2date(get_option('date_format'), $comment->comment_date_gmt);
	else
		$date = mysql2date($d, $comment->comment_date_gmt);
	return apply_filters('get_comment_date', $date, $d);
}

> 呼呼,小邪把 $comment->comment_date 修改为 $comment->comment_date_gmt 就正常了。
> 搞定鸟,现在直接显示 GMT 处的时间,修改的文件是 /wp-includes/comment-template.php。

> P.s. Linux 的 VPS 时间和时区是完全与母机同步的,所以我们就木有办法去修改 VPS 的时间了额。

二. Linux 常用命令:

-bash-3.2# ls
bak.sh  downloads  home  lnmp  nconf  pureftpd  run.sh
//这个命令和 Windows 下面的 Dir 原理相同
-bash-3.2# ls -al
//这个命令可以同时查看文件的权限大小以及修改日期等等信息
total 40
drwxr-x---  3 root root 4096 Jul  8 05:43 .
drwxr-xr-x 21 root root 4096 Jul  6 02:16 ..
-rw-------  1 root root 9858 Jul  8 22:03 .bash_history
-rwxrwxrwx  1 root root  575 Jul  8 04:55 bak.sh
drwxr-xr-x  3 root root 4096 Jul  6 08:14 downloads
lrwxrwxrwx  1 root root    5 Jul  6 06:53 home -> /home
-rwxr-xr-x  1 root root 2628 Jul  5 23:53 lnmp
lrwxrwxrwx  1 root root   21 Jul  8 05:43 nconf -> /usr/local/nginx/conf
-rwxr-xr-x  1 root root 1335 Jul  6 09:03 pureftpd
-rwxrwxrwx  1 root root   80 Jul  5 23:53 run.sh
-bash-3.2# df -lh
//这个命令可以查看磁盘信息
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             9.6G  2.3G  6.9G  25% /
-bash-3.2# top
//这个命令就像任务管理器一样,按 Shift+< Shift+> 翻页
top - 22:25:53 up 2 days, 20:10,  1 user,  load average: 0.02, 0.03, 0.00
Tasks:  53 total,   1 running,  52 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.4%us,  0.0%sy,  0.0%ni, 99.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    262320k total,   249892k used,    12428k free,    21116k buffers
Swap:   524280k total,       32k used,   524248k free,    84420k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      15   0  2172  740  640 S  0.0  0.3   0:00.06 init
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/0
    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
    7 root      12  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
    9 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 xenwatch
   10 root      17  -5     0    0    0 S  0.0  0.0   0:00.00 xenbus
   16 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kblockd/0
   17 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 cqueue/0
   21 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 khubd
   23 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod
   83 root      15   0     0    0    0 S  0.0  0.0   0:00.02 pdflush
   84 root      15   0     0    0    0 S  0.0  0.0   0:00.02 pdflush
   85 root      10  -5     0    0    0 S  0.0  0.0   0:00.08 kswapd0
   86 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0
-bash-3.2# ls
bak.sh  downloads  home  lnmp  nconf  pureftpd  run.sh
-bash-3.2# cd downloads
//cd 命令和 Windows 下面用法几乎一样,但是返回上层目录是 cd ../
-bash-3.2# ls
lnmp0.4-full.tar.gz  openvpn-as-1.5.0-CentOS5.x86_64.rpm
lnmpi                pptpd-1.3.4-1.rhel5.1.i386.rpm
-bash-3.2#

三. 尾声:

> 某子曾经日过 - 革命还木有成功,同志们还要继续努力。╮(╯▽╰)╭。春哥会保佑你们,╮(╯O╰)╭。

Leave a comment
30 Comments.
  1. winy Mozilla Firefox Windows 坐沙发!#1

    沙发

    @
  2. 林木木 Google Chrome Windows 坐板凳!#2

    chrome下侧边栏下掉了……

    @
    • @林木木 , ( ⊙o⊙ ),( ⊙o⊙ ),额滴神 ~ 可能是导航栏太多字了 ~
      现在应该好了,经过 Chrome Opear IE6 Firefox Safari 测试正常 ~

      @
  3. 久酷 Mozilla Firefox Windows 躺地板!#3

    春哥保佑,哈哈

    @
  4. mice Internet Explorer Windows 天花板!#4

    :evil: 回来更新真勤快

    @
  5. 猪八戒 Mozilla Firefox Windows 下水道!#5

    时间确实有时候出现差错。

    @
  6. fatkun Google Chrome Windows 地心!#6

    日过。。。 :mrgreen: 加勒个油

    @
  7. 还好我的vps 母鸡时间是对着的

    @
  8. 对了,小邪,你这是用的哪里VPS?哪个机房的? 速度很好……
    PS.你这儿留言回复没有邮件提示?

    @
  9. 我也发现了,在垃圾邮件列表

    @
  10. :redface: 俺去修改修改一下·· :rolleyes:

    @
  11. 学习了 呵呵 不错

    @
  12. 小X,你终于又活过来了?! 你的博客好长时间不能访问。。。。

    @
  13. 想到你这找个教程都打不开,急死我了!这下好了。
    还有,看去消息上QQ,我给你留言了。
    联盟新成立了技术团队,你有空就加进来。
    QQ群:76800395

    @
  14. :redface: :redface: :redface: :redface:

    @

Leave a Reply


[ Ctrl + Enter ]