In PHP, you can get another date by adding or subtracting a few days to a certain date. We will use two examples to illustrate. One is strtotime and mktime to convert the time into a timestamp and then process it. Students in need can take a look. .
The following example: get the date one day before 2012-5-1
The code is as follows
|
Copy code
|
||||||||||||||||
//Convert time point to timestamp $date = strtotime('2012-5-1'); //Output the date one day ago, subtract the number of seconds of the day from the timestamp
?>
Output: 2012-4-30 In addition, the time() function gets the timestamp of the current date!
Previous article:PHP perfect paging program_PHP tutorial
Next article:PHP does site search and highlights keywords_PHP tutorial
Statement of this Website
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
Latest Articles by Author
Latest Issues
When adding sublime3 to compile system php, use the PHP toolbox, cmd php -v is useless
From 1970-01-01 08:00:00
0
0
0
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|