用strtotime函数
这是我写的例子<?php
function ch_strtotime($d) {
  $ar = array(
    array("/今天|现在/","now "),
    array("/昨|上|去/","-1 "),
    array("/明|下/","+1 "),
    array("/^前/","-2 "),
    array("/^后/","+2 "),
    array("/年/"," year "),
    array("/月/"," month "),
    array("/周|星期/"," week "),
    array("/天|日/"," day"),
    array("/小时/"," hours "),
    array("/分/"," minutes "),
    array("/秒/"," seconds "),
    array("/(.+)后/","-\\1"),
    array("/(.+)前/","-\\1")
  );
  for($i=0;$i<count($ar);$i++) {
    $patterns[$i] = $ar[$i][0];
    $replace[$i] = $ar[$i][1];
  }
  $d = preg_replace($patterns,$replace,$d);
  echo "<br>",date("Y-m-d H:i:s",strtotime($d));
}// 例
ch_strtotime("现在");
ch_strtotime("去年");
ch_strtotime("1小时3分40秒");
?>