PHP date formatting example analysis, PHP formatting example analysis
The example in this article describes how to format dates in PHP. Share it with everyone for your reference.
The specific implementation code is as follows:
Copy code The code is as follows:
function ShowDate($flag=0, $timestr=NULL)
{
// Get the day of the week
$warr = array(
"0" => Sunday,
"1" => Monday,
"2" => Tuesday,
"3" => Wednesday,
"4" => Thursday,
"5" => Friday,
"6" => Saturday
);
$i = date("w", $timeStamp);
//Set Beijing time and get timestamp
Date_default_timezone_set('PRC');
$timeStamp = NULL;
If ($timestr)
$timeStamp = strtotime($timestr);
else
$timeStamp = time();
// Set the time display format
$ret1 = date("Y year m month d day 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; // Return the first type by default
If ($flag == 2)
$ret = $ret2;
else if ($flag == 3)
$ret = $ret3;
Return $ret;
}
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/910608.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/910608.htmlTechArticlePHP format date example analysis, php formatting example analysis This article describes the method of php formatting date. Share it with everyone for your reference. The specific implementation code is as follows: Copy code...
Statement: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