php format date
- 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 one by default
-
- if ($flag == 2)
- $ret = $ret2;
- else if ($flag == 3)
- $ret = $ret3;
-
- return $ret;
- }
Copy code
- 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 one by default
-
- if ($flag == 2)
- $ret = $ret2;
- else if ($flag == 3)
- $ret = $ret3;
-
- return $ret;
- }
Copy code
|