Php format date instance analysis, php format instance analysis. Php formatting date instance analysis, php formatting instance analysis this article describes the php formatting date method. Share it with you for your reference. The specific implementation code is as follows: Copy the code php format date instance analysis, php format instance analysis
This example describes how to format a date in php. Share it with you for your reference.
The specific implementation code is as follows:
The code is as follows:
Function ShowDate ($ flag = 0, $ timestr = NULL)
{
// Obtain the number of weeks
$ Warr = array (
"0" => Sunday,
"1" => Monday,
"2" => Tuesday,
"3" => Wednesday,
"4" => Thursday,
"5" => Friday,
"6" => Saturday
);
$ I = date ("w", $ timeStamp );
// Set the Beijing time and obtain the timestamp
Date_default_timezone_set ('prc ');
$ TimeStamp = NULL;
If ($ timestr)
$ TimeStamp = strtotime ($ timestr );
Else
$ TimeStamp = time ();
// Set the time display format
$ 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; // The first type is returned by default.
If ($ flag = 2)
$ Ret = $ ret2;
Else if ($ flag = 3)
$ Ret = $ ret3;
Return $ ret;
}
I hope this article will help you with PHP programming.
Examples in this article describes how to format a date in php. Share it with you for your reference. The specific implementation code is as follows :...