PHP Get the date list 30 days before the current date_PHP Tutorial

WBOY
Release: 2016-07-13 10:31:24
Original
1614 people have browsed it

Recently, the project requires a statistical function to count the records of the previous 30 days before the current date. The function is quite simple. I will share with you the implementation method below for the convenience of friends in need.

In fact, it mainly uses the strtotime function of php, strtotime('n day'), the example is as follows:

$days=array();
for($i=0;$i<=7;$i++){//这里数字根据需要变动
	$days[]=date("Y-m-d",strtotime('-'.$i.'day'));
}//http://www.phpernote.com/php-function/970.html
echo '<pre class="brush:php;toolbar:false">';print_r($days);
Copy after login

The results will appear as follows:

Array
(
[0] => 2014-03-21
[1] => 2014-03-20
[2] => 2014-03-19
[3] => 2014-03-18
[4] => 2014-03-17
[5] => 2014-03-16
[6] => 2014-03-15
[7] => 2014-03-14
)

Articles you may be interested in

  • How to get a list of dates within a period of time with PHP
  • The reason why PHP adds a backslash before the quotation marks And how to remove backslashes in PHP, three ways to turn off php magic quotes
  • JavaScript gets the current date and time and displays the day of the week
  • PHP gets the week and the first day of the month for the specified date and the last day
  • php function to calculate how many days (days) the difference between two dates is
  • php gets the timestamp of the start time and end time of the week on the specified date
  • php Methods to obtain the chronology, zodiac and constellation information based on date or timestamp
  • PHP function to extract the birthday date from the ID number and verify whether it is a minor

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764087.htmlTechArticleRecently, the project requires a statistical function to count the records of the previous 30 days before the current date. The function is quite simple. I will share with you the implementation method this time for your convenience...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!