The versatility and proximity of PHP functions is a great feature the same application can be implemented in a variety of functions, which is probably a disadvantage of open source; Through the system of PHP time function learning, fully understand the timestamp and time zone concept (this is really important), the need for small partners can refer to.
All functions in PHP are in the Unix era, starting January 1, 1970.
The date is the number of seconds to start at this time.
When a function call is counted as a number of seconds from this time, it is treated as a (timestamp) timestamp.
local time function
1. String date (string Format,inieger timestamp)
The function returns a string representing the time, which is controlled by the string format.
Such as:
?
1 2 3 4 |
? Print (Date ("Y year M month D Day");/output current, month/day. Print (date ("Y year M month D Day", 60*60*24*365*10);//Output January 1, 1980.?> |
Perhaps you would ask, "How come there is no timestamp?" If timestamp is empty, or does not write, it indicates that the current time timestamp is used.
The control character that represents the year: Y---Four-bit year y---two-bit years
The control character that represents the month: M---The month name from 1-12 months F---English month name m---abbreviated month
The control character that represents the day number: D---0 of the month before the date j--there is no 0 in front of the day number
The control character for the week: l--English week d--Week
The control character that represents the hour: h--from 1-12 hours h---from 0 to 23 hours
Represents the control character a---am or pm a---am or PM in the afternoon
The control character that represents the minute: I---Take a value of 00-59
How many days of the year: z--the number of days of the year
2. Array getdate (integer timestamp)
The function returns a matrix.
Such as:
?
1 2 3 4 5 6 |
? $current _date=getdate (); Print ($current _date ("hours")); Print ($current _date ("minutes"); Print ($current _date ("seconds");?> |
Description
Element description
Hours 24-hour format hour
Mday date in month
Minutes minutes
Mon numeric form of the month
Month Month full name
Seconds number of seconds
Wday from 0 to 6 of the number of weeks of the form
Weekday the name of the day of the week
Year years
0 time stamp that's the number of seconds from January 1, 1970 to now
Yday the date of the year in digital form
3. Boolean checkdate (integer month,integer day,integer year)
This function checks whether the date is legal. For example:
?
1 2 3 4 |
? if (Checkdate (2,29,1980)) print ("date valid!n");?> |
4. Integer time ()
This function obtains the current timestamp. For example:
?
1 2 3 |
? Print (Time ());//output a large string of integers?> |
5. Integer mktime (integer hour,integer minutes,integer seconds,integer month, integer day,integer year)
This function returns the time stamp for the date, that is, the number of seconds from January 1, 1970 to today.
If a parameter is out of range, the function can also explain it, as 1 March is the second year of January.
Such as:
?
1 2 3 4 5 6 |
? $currenthour =date ("H"); Print ("50 hours later:"); Print (Date ("H:i A L F ds,y", Mktime ($currenthour +50)); Print ("<br>n");?> |
6. String Microtime ()
The function returns a string, the number of milliseconds from the current time + space + the number of seconds starting in 1970
?
1 2 3 4 5 6 |
? Print ("Start:microtime () <br>n"); For ($index =0 $index <1000; $index + +) print ("good!"); Print ("Stop:microtime () <br>n");?> |
Also, the Linwei standard Time function
The above mentioned is the entire content of this article, I hope you can enjoy.
Note < > : More Wonderful tutorials please focus on Triple programming