This article introduces the time function in PHP and Mktime () in the usage of the difference between the need for a friend to refer to it. In PHP programming, the Time Function times () returns the current time. The Mktime () function, instead of returning the current time, is the format time. Although writing mktime () alone does not add any parameters such as Echo mktime () and Echo time (), the effect is the same. But it's not the same in nature. PHP mktime () function php date/time function The definition and usage of the mktime () function returns a Unix timestamp for a date. The parameter always represents the GMT date, so IS_DST has no effect on the result. Parameters can be left-to-right and empty, and empty parameters will be set to the corresponding current GMT value. Grammar Mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST) Parameter description Hour is optional. Specified hours. Minute is optional. Specify minutes. Second is optional. Specify seconds. Month is optional. Specifies the number of months to be represented. Day is optional. Prescribed days. Year is optional. Prescribed year. On some systems, the legal value is between 1901-2038. However, there is no such limit in PHP 5. IS_DST is optional. If the time is in daylight saving time (DST), set to 1, otherwise set to 0 and if unknown, set to-1.Since 5.1.0, the IS_DST parameter has been discarded. Therefore, you should use the new Time zone processing feature. Hints and comment notes: Before PHP 5.1, if the parameters of the function are illegal, it will return false. Example: the Mktime () function is useful for date arithmetic and validation. It can automatically correct out-of-bounds input:
Output: jan-05-2002feb-01-2002jan-01-2001jan-01-1999 PHP time () function PHP date/time function Define and use the time () function to return the Unix timestamp for the current time. Syntax time (void) Parameter description void is optional. The description returns the number of seconds since the Unix era (January 1, 1970 00:00:00 GMT) to the current time. Hints and notes: From PHP 5.1, the timestamp of the time the request was initiated was saved in $_server[' Request_time '. Example 1,
Echo (Date ("D F D Y", $t)); >
Output: 1138618081Mon January 30 2006 Example 2,
Output: Now:2005-03-30next week:2005-04-07 >>> you may be interested in the article: PHP in Time (), date (), mktime () The difference between PHP strtotime () and mktime () y2k38 Vulnerability 2038 problem PHP Application Mktime get timestamp example analysis |