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
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|