1, year-month-day
Echo date ('Y-m-J ');
2007-02-6
Echo date ('Y-n-J ');
07-2-6
Uppercase y indicates four digits of the year, while lowercase y indicates two digits of the year;
Lowercase M indicates the number of the month (with the leading digit), while lowercase n indicates the number of the month without the leading digit.
Echo date ('Y-m-J ');
2007-feb-6
Echo date ('Y-m-d ');
2007-02-06
Uppercase M indicates the three abbreviations of the month, while lowercase M indicates the number of the month (with leading 0 );
There is no upper-case J. only lower-case J indicates the date of the month, and there is no leading O. If the month needs to have the upper-case J, the lower-case D is used.
Echo date ('Y-m-J ');
2007-feb-6
Echo date ('Y-F-js ');
2007-february-6th
Uppercase M indicates the three abbreviated characters of the month, while uppercase F indicates the full English Writing of the month. (No lower case F)
Uppercase s indicates the suffix of a date, such as "St", "nd", "RD", and "th". For details, see the date number.
Summary:
Y indicates that the year can be in uppercase or lowercase y;
Indicates that the month can be written in uppercase letters (F), uppercase letters (M), lowercase letters (M), and lowercase letters (n );
Indicates the date suffix.
2, hour: minute: Second
By default, PHP interprets the display time as "Greenwich Mean Time", which is 8 hours different from our local time.
Echo date ('G: I: s ');
5:56:57 AM
Echo date ('H: I: s ');
05:56:57 AM
Lowercase G indicates the 12-hour system, with no leading 0, while lowercase h indicates the 12-hour system with leading 0.
When the 12-hour format is used, it indicates that upper afternoon, lower case A indicates lower case "am" and "PM", and upper case A indicates upper case "am" and "PM ".
Echo date ('G: I: s ');
14:02:26
Uppercase G indicates the number of hours in the 24-hour format, but does not contain the leading value. uppercase h indicates the number of hours in the 24-hour format.
Summary:
The letter G indicates that the hour does not contain a leading character, and the letter h indicates that the hour contains a leading character;
Lowercase G and H are in 12-hour format, while uppercase G and H are in 24-hour format.
3, leap year, week, day
Echo date ('l ');
This year's leap year: 0
Echo date ('l ');
Today is: Tuesday
Echo date ('D ');
Today is: TUE
Capital L indicates whether to determine the leap year Of The Year. If it is true, 1 is returned; otherwise, 0 is returned;
Lowercase L indicates the day of the week in full (Tuesday );
However, uppercase D is used to represent the three abbreviation of the day of the week (Tue ).
Echo date ('W ');
Today's week: 2
Echo date ('W ');
This week is the 06th week of the year.
Lowercase W indicates the day of the week, expressed in numbers
In upper case, W indicates the number of weeks in a year.
Echo date ('T ');
This month is 28 days
Echo date ('Z ');
Today is the 36th day of this year
Lowercase t indicates the number of days in the current month
Lowercase Z indicates that today is the day of the year
4. Others
Echo date ('T ');
UTC
Uppercase t indicates the time zone setting of the server
Echo date ('I ');
0
If I is used to determine whether the current value is success, 1 is returned for true. Otherwise, 0 is returned.
Echo date ('U ');
1170769424
The upper-case u table shows the total number of seconds from January 1, January 1, 1970 to the present, which is the Unix timestamp of the UNIX time era.
Echo date ('C ');
2007-02-06t14: 24: 43 + 00: 00
Lowercase c Represents the iso8601 date, the date format is YYYY-MM-DD, with the letter T to interval the date and time, the time format is hh: mm: SS, the time zone uses Greenwich Mean Time (GMT).
Echo date ('R ');
Tue, 06 Feb 2007 14:25:52 + 0000
Lowercase R indicates the rfc822 date.
Instance: CopyCode The Code is as follows: <? PHP
/*
@ Author hills
@ Tencentqq 3303911:
@ Web www.abzz.net
@ Email hackhgs@qq.com
@ Blog blog.abzz.net
@ Mobiletelethone 1345-2626-567
@ Filecreate 2009-12-25-, copyright hills
*/
$ UTC = Date ("T ");
If ($ UTC = "UTC ")
$ H = date ("H") + 8;
$ Dateshow = date ("Y-m-d". $ H. ": I: s ");
Function RN ()
{
If (date ("L") = 1)
{
Echo "yes ";
}
Else
{
Echo "no ";
}
}
$ Weeks = Date ("L ");
$ Year = date ("W ");
$ Dayyear = date ("Z ");
$ Weeksmemberic = Date ("T ");
?>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/5o/xhtml">
<Head>
<Meta http-equiv = "X-UA-compatible" content = "Ie = emulateie7"/>
<Meta http-equiv = "content-language" content = "ZH-CN"/>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Meta http-equiv = "keywords" content = "date () function"/>
<Meta http-equiv = "Description" content = "date () function"/>
<Meta http-equiv = "author" content = "hills"/>
<Title> date () function </title>
<Link href = "CSS/default.css" rel = "stylesheet" Media = "all" type = "text/CSS"/>
</Head>
<Body>
<Div>
<Div>
<Ul>
<Li> <? PHP echo "Time Zone:". $ UTC;?> </LI>
<Li> <? PHP echo "current time (+ 8):". $ dateshow;?> </LI>
<Li> <? PHP echo ("leap year:"); RN ();?> </LI>
<Li> <? PHP echo "Week:". $ weeks;?> </LI>
<Li> <? PHP echo "Today is the Year's Day:". $ year. "Week";?> </LI>
<Li> <? PHP echo "Today is the first day of this year". $ dayyear. "day";?> </LI>
<Li> <? PHP echo "1st day of this month total". $ weeksmemberic. "day";?> </LI>
</Ul>
</Div>
</Div>
</Body>
</Html>