php實現格式化日期
function ShowDate($flag=0, $timestr=NULL) { // 獲取周幾 $warr = array( "0" => 星期日, "1" => 星期一, "2" => 星期二, "3" => 星期三, "4" => 星期四, "5" => 星期五, "6" => 星期六 ); $i = date("w", $timeStamp); // 設置北京時間並獲取時間戳 date_default_timezone_set('PRC'); $timeStamp = NULL; if ($timestr) $timeStamp = strtotime($timestr); else $timeStamp = time(); // 設置時間顯示格式 $ret1 = date("Y年m月d日 H:m:s", $timeStamp) . " " . $warr[$i]; $ret2 = date("Y-m-d H:m:s", $timeStamp) . " " . $warr[$i]; $ret3 = date("y/m/d", $timeStamp); $ret = $ret1; // 默認返回第一種 if ($flag == 2) $ret = $ret2; else if ($flag == 3) $ret = $ret3; return $ret; }
詳細說明:http://php.662p.com/thread-488-1-1.html