Commonly used 1. Convert Unix timestamp into a format similar to "2012-05-12 11:09:15": date('Y-m-d H:i:s',$time); //$ The value of time is the Unix timestamp, which may be what you took out from the database or... 2. Convert the time in the "2012-05-12" format into a timestamp: strtotime("2012- 05-12"); //The return value is int type 3. Print the timestamp of the current time: echo(time()); Advanced In fact, the date function provided by PHP The function is very easy to use. For example, if you want to convert a Unix timestamp into the date format you want, such as "May 25, 2012": date('Y year m month d day', $time) ; You can see that the date function is only interested in "Y", "m", and "d". As for the special characters you inserted in the middle, she doesn't pay much attention. ■Year--"Y" represents the four-digit year. 2012 ■Year--"y" represents a two-digit year. 12 ■month--"F" means spelling out the English month. January will be displayed as "january" ■month--"M" represents the first 3 characters of the English month. The month of January will be displayed as "jan", the abbreviation of January ■month - "m" represents the numeric month. January is displayed as "01" and December is "12" ■Day--"j" represents a numeric date. If the date is a single digit, "0" will not be added to the high digit, for example: "9", "12" ■Day - "d" represents a numeric date. If the date is a single digit, the high digit will be filled with "0", for example: "09", "12" ■hour - "g" The time in twelve-hour format, if it is a single digit, the high digit will not be filled." 0", for example: "3", "12" ■Hour - "G" is the time in the twenty-four-hour format. If it is a single-digit high digit, "0" will not be added, for example: "3", " 18" ■hour-"h"Twelve-hour time, if it is a single-digit high digit, "0" will be added, for example: "03", "12" ■hour-"H" If the time in the 24-hour format is a single digit, "0" will be added to the high digit, for example: "03", "18" ■ minutes - "i" minutes, for example: "09", "60" ■Seconds--"s" seconds, such as: "06", "60" Finally, please note that if the time format is output in the twelve-hour format, you need to indicate AM and PM For example: echo date('g:i:s a'); The output result is: 5:56:57 am echo date('h:i:s A'); The output result is: 05: 56:57 AM "a" morning = am, afternoon = pm; "A" morning = AM, afternoon = PM Popular science The timestamp is from January 1, 1970 (00:00: 00 GMT). It is also called Unix Timestamp. Unix timestamp (Unix timestamp), also known as Unix time (Unix time), POSIX time (POSIX time), is a time representation method, defined as starting from 00:00 Greenwich Mean Time on January 1, 1970 The total number of seconds since minute 00 seconds. Unix timestamps are not only used in Unix systems and Unix-like systems, but are also widely used in many other operating systems.
The above introduces PHP's conversion of Unix timestamps, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn