Finishing Live: PHP's date and time function date ()

2010-12-15  来源:本站原创  分类:PHP  人气:92 

Finishing Live: PHP's date and time function date ()

1, Year - Month - Day
echo date ('Ym-j');
2007-02-6

echo date ('yn-j');
07-2-6

Y said the four-digit years uppercase and lowercase y, said double-digit year;
Lower case m represents the month number (with leading), while the lowercase n indicates the month without leading numbers.

echo date ('YM-j');
2007-Feb-6

echo date ('Ym-d');
2007-02-06

Uppercase M 3 of the month abbreviation characters, and lowercase m indicates the number of the month (with leading 0);
No uppercase J, only the lower case j represents the month of the date, no leading o; If you need to use the month with a leading lowercase d.

echo date ('YM-j');
2007-Feb-6

echo date ('YF-jS');
2007-February-6th

Uppercase M 3 of the month abbreviation characters, and the English capital F represents the month in full. (No lowercase f)
Capital S represents the date of the suffix, such as "st", "nd", "rd" and "th", the specific date to see a breakdown.

Summary:
That can be used in uppercase and lowercase Y y;
That can be used on capital F, capital M, lowercase m and the lower case n (respectively, two ways of characters and numbers);
That can be used at lower-case d and lower case j, upper case S represents the date of the suffix.

2 hours: minutes: seconds

By default, PHP shows the time to explain as "Greenwich Mean Time", and our local time is 8 hours.

echo date ('g: i: s a');
5:56:57 am

echo date ('h: i: s A');
05:56:57 AM

Lower case g said the 12-hour, no leading 0, and lowercase h indicates a leading 0 to 12 hour clock.
When you need 12-hour show on the afternoon, said a lower case lower case "am" and "pm", said the uppercase uppercase A "AM" and "PM".

echo date ('G: i: s');
14:02:26

G said the 24-hour caps the number of hours, but without leading to; use uppercase H, said the 24-hour clock with leading Hours

Summary:
The letter g for hours without leading, the letter h is the hour with leading;
Lower case g, h said the 12-hour clock, uppercase G, H, said 24 hours.

3, a leap year, weeks, days

echo date ('L');
This year is a leap year: 0

echo date ('l');
Today is: Tuesday

echo date ('D');
Today is: Tue

Year to determine whether capital L that leap, Boolean value, is true returns 1, otherwise 0;
Lowercase l that the day of the week in English in full (Tuesday);
The day of the week uppercase D to 3-character abbreviation (Tue).

echo date ('w');
Day of the week: 2

echo date ('W');
This week is the first 06 weeks throughout the year

Lowercase w day of the week, said the capital W in digital form, said the number of weeks a year

echo date ('t');
This month is 28 days

echo date ('z');
Today is the first 36 days this year

Lowercase t represents the current month and the number of days that today is the lowercase z in the first few days of this year

4, other

echo date ('T');
UTC
Capital T means that the server's time zone settings

echo date ('I');
0
I said that the current capital to determine whether daylight saving time, is true returns 1, otherwise 0

echo date ('U');
1170769424
Uppercase U said that from January 1, 1970 to the present total number of seconds, that is, the UNIX timestamp Unix time epoch.

echo date ('c');
2007-02-06T14: 24:43 +00:00
ISO8601 lowercase c that date, the date format YYYY-MM-DD, the letter T to the interval with the date and time, time format is HH: MM: SS, use the Time Zone Greenwich Mean Time (GMT) to represent the deviation.

echo date ('r');
Tue, 06 Feb 2007 14:25:52 +0000
Lowercase r that RFC822 date.

Small date () PHP function to display the power and charm, and then compare the next ASP, hehe.

PHP in the Baidu search the complete date and time function date () the content, or to use Google search more relevant

相关文章
  • Finishing Live: PHP's date and time function date () 2010-12-15

    Finishing Live: PHP's date and time function date () 1, Year - Month - Day echo date ('Ym-j'); 2007-02-6 echo date ('yn-j'); 07-2-6 Y said the four-digit years uppercase and lowercase y, said double-digit year; Lower case m represents the month numbe

  • MySQL date and time function finishing 2010-11-15

    A, MySQL access to the current date and time functions 1.1 to obtain the current date + time (date + time) function: now () mysql> select now (); +---------------------+ | Now () | +---------------------+ | 2008-08-08 22:20:46 | +--------------------

  • mysql date function - date back to subtract the number of days 2010-06-06

    MySQL datediff (date1, date2): subtracting two dates date1 - date2, return the number of days. select datediff ('2008-08-08 ', '2008-08-01'); - 7 select datediff ('2008-08-01 ', '2008-08-08'); - -7 Reference: MySQL: date function, time function sum (

  • php gmdate function - date and time library 2010-06-26

    After obtaining the current time difference with GMT. Syntax: string gmdate (string format, int timestamp); Return value: string function types: the time and date Content of this function with the date () function is similar, except that this functio

  • PHP Warning: date () [function.date] 2010-07-17

    In use for more than PHP5.3 PHP version, as long as the time involved will report a "PHP Warning: date () [function.date]: It is not safe to rely on the system's timezone settings. You are * required * to use the date.timezone setting or the date_def

  • Date time format function object 2010-08-28

    /** * Time formatting objects ; */ Date.prototype.format = function(format){ /* * eg:format="YYYY-MM-dd hh:mm:ss"; */ var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(),

  • DB_MySQL_ date type _ function 2010-08-29

    For the network the following excerpt, leave a backup For each type has a value range and the time value and specify the effective date of any description of the format the date and time types, see 7.3.6. Here is an example of using the date function

  • PHP Warning: date() [function.date]: It is not ... 2013-10-18

    PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone 在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个 "PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.tim

  • java date format handling Daquan Date format SimpleDateFormat 2010-03-29

    Java In the date format conversion /** * Convert java string .util.Date<br> * Support the format yyyy .MM.dd G 'at' hh:mm:ss z As '2002-1-1 AD at 22:10:59 PSD'<br> * yy/MM/dd HH:mm:ss As '2002/1/1 17:55:00'<br> * yy/MM/dd HH:mm:ss pm As

  • [Change] Java.util.date and java.sql.date difference and change 2010-08-02

    1, will be converted to java.sql.Date java.util.Date java.sql.Date sd; java.util.Date ud; / / Initialize the ud such as ud = new java.util.Date (); sd = new java.sql.Date (ud.getTime ()); 2, to insert into the database and the corresponding field for

  • Reprint: java.util.Date and java.sql.Date and transformation of the difference between 2010-08-05

    java.util.Date is the case in addition to the following SQL statement to use java.sql.Date is used for SQL statements, it only contains the date and time for some of it did not have the getTime method returns the number of milliseconds, naturally, ca

  • java.util.Date and java.sql.Date system conversion and converted to a date time format string 2010-11-26

    1, will be converted to a java.sql.Date java.util.Date java.sql.Date sd; java.util.Date ud; / / Initialize the ud such as ud = new java.util.Date (); sd = new java.sql.Date (ud.getTime ()); 2, to insert into the database and the corresponding field f

  • jstl in the date format, string to date, String conversion Date 2010-08-26

    *** Of the problem: Written in very old people to change the code, the data is hibernate mapping to the mysql table, we may then strut tags are not used to using, jstl <c: out tag very popular class. Database field is Date, indeed is mapped to String

  • Java.util.date and java.sql.date difference and change 2010-09-19

    1, will be converted to java.sql.Date java.util.Date java.sql.Date sd; java.util.Date ud; / / Initialize the ud such as ud = new java.util.Date (); sd = new java.sql.Date (ud.getTime ()); 2, to insert into the database and the corresponding field for

  • Javascript: date string (DateStr) and the date of the object (Date) the conversion between 2010-11-18

    Directly into the topic: Create a Date object: var objDate = new Date ([arguments list]); Form of the following 5 parameters: view plaincopy to clipboardprint? new Date ("month dd, yyyy hh: mm: ss"); new Date ("month dd, yyyy"); new Da

  • Convert java.sql.Date to java.util.Date 2011-01-08

    [B] Method One: java.sql.Date sd; java.util.Date ud; / / Initialize the ud such as ud = new java.util.Date (); sd = new java.sql.Date (ud.getTime ()); Method Two: java.util.Date date = new java.util.Date (); / / 1. Set format java.text.SimpleDateForm

  • java.util.Date和java.sql.Date的区别和相互转化 2013-01-21

    java.util.Date和java.sql.Date的区别和相互转化 分类: java相关 2011-07-22 10:43 4533人阅读 评论(0) 收藏 举报 java.util.Date是在除了SQL语句的情况下面使用的. java.sql.Date是针对SQL语句使用的,它只包含日期而没有时间部分 它 们都有getTime方法返回毫秒数,自然就可以直接构建. java.util.Date 是 java.sql.Date 的父类,前者是常用的表示时间的类,我们通常格式化或者得到当前时

  • php getdate function - date and time library 2010-06-17

    Access time and date information. Syntax: array getdate (int timestamp); Return value: array of function types: the time and date Content returns an array of elements include the following items: <ul type=disc> "Seconds" - seconds "Mi

  • php gettimeofday function - date and time library 2010-06-21

    Get the current time. Syntax: array gettimeofday (void); Return value: array of function types: the time and date Content returns an array of elements include the following items: <ul type=1> "Sec" - seconds "Usec" - millionth of

  • php gmmktime function - date and time library 2010-06-26

    To obtain GMT UNIX timestamp. Syntax: int gmmktime (int hour, int minute, int second, int month, int day, int year); Return value: integer function types: the time and date Content input a time, then return to UNIX timestamp in Greenwich, a long inte