Of course, the date function of PHP is not possible to directly output the date of the Chinese, but you can use the following method to write a function.
The code is as follows |
Copy Code |
function today () { Date_default_timezone_set ("asia/chongqing"); $a =date ("Y"); $b =date ("M"); $c =date ("D"); $d =date ("G"); $e =date ("I"); $f =date ("s"); return $a. $b. ' Month ', $c, ' Day ', $d ', $e. ' Minute '. $f. ' Seconds '} |
If the echo date ("y-m-d") appears;
Alarm:
warning:date () [function.date]: It is isn't safe to rely on the system ' s timezone settings. You are are *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you are used any of those methods and your are still getting this warning, for you most likely misspelled the timezone Iden Tifier. We have selected ' UTC ' for ' 8.0/no DST ' instead in g:sourcetestceshimktime.php on line 4
online to find out why, below to share:
When using the PHP version above PHP5.3, as long as it is involved in time will report a
"php warning:date () [function.date]: It is not safe to rely on the system ' s TimeZone settings. You are are *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you are used any of those methods and your are still getting this warning, for you most likely misspelled the timezone Iden Tifier. We selected ' UTC ' for ' 8.0/no DST ' instead in
Here are three methods (any of which can be selected):
First, in the page using Date_default_timezone_set () Set Date_default_timezone_set (' PRC '); East Eight time zone echo date (' y-m-d h:i:s ');
Second, the use of Ini_set (' Date.timezone ', ' Asia/shanghai ') in the head of the page;
Third, modify the php.ini. Open Php5.ini Find Date.timezone Remove the preceding semicolon modify to become: Date.timezone =PRC
Restart the HTTP service (such as Apache2 or IIS, etc.).
About the Date function argument
Day of the D month, 2 digits 01 to 31 with leading zeros
D the first day of the week, the text says, 3 letters Mon to Sun
Day of the J month, no leading 1 to 31
L ("l" lowercase) day of the week, complete text format Sunday to Saturday
N ISO-8601 format Number of days of the week (PHP 5.1.0 new) 1 (Monday) to 7 (Sunday)
S the English suffix after the number of days of the month, 2 characters st,nd,rd or th. Can be used with J.
The first days of the W week, the numbers indicate 0 (Sunday) to 6 (Saturday)
Day 0 to 366 in the z year
W ISO-8601 Format The first weeks of the year, starting from Monday (PHP 4.1.0 New) 42 (42nd Week of the year)
F month, full text format, such as January or March January to December
The month represented by the m number, with a leading 1 to 12
The month of the M three-letter abbreviation to DEC
n Numeric month, no leading 1 to 12
T 28 to 31 days in a given month
L is a leap year if it is a leap year for 1, otherwise 0
o ISO-8601 format year numbers.
Y 4 digits fully represented year for example: 1999 or 2003
Y 2-digit year for example: 99 or 03
A lowercase morning and afternoon value am or PM
A capital of the morning and afternoon value AM or PM
B Swatch Internet Standard 000 to 999
G-hour, 12-hour format, no leading 1 to 12
G-hour, 24-hour format, no leading 00 to 23
H-hour, 12-hour format, with leading 1 to 12
H-hour, 24-hour format, with leading 000 to 23
I have a leading zero number of minutes 00 to 59>
s seconds, with leading 000 to 59>
E Time zone identification (PHP 5.1.0 new) For example: Utc,gmt,atlantic/azores
I is daylight saving time if daylight saving time is 1, or 0
O the number of hours that differs from GMT for example: +0200
The difference between P and GMT (GMT), the hours and minutes are separated by colons, for example: +02:00
T the time zone where this machine is located
The number of seconds for the Z-slack offset. The time zone offset to the west of UTC is always negative, and the East side of UTC is positive. -43200 to 43200
C ISO 8601 format date (PHP 5 new addition) 2004-02-12t15:19:21+00:00
R RFC 822 Format date For example: Thu, DEC 2000 16:01:07 +0200
U get timestamp from the number of seconds since the Unix era (January 1 1970 00:00:00 GMT) has started ()
PHP's date () function is very powerful, through these parameters can achieve a lot of date operations, such as getting the above I marked the red parameter description to achieve today is the day of the week operation!