Home > php教程 > php手册 > php实现格式化日期,php格式化日期

php实现格式化日期,php格式化日期

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:21:29
Original
1455 people have browsed it

php实现格式化日期,php格式化日期

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;  
}
Copy after login

  详细说明:http://php.662p.com/thread-488-1-1.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template