Home > php教程 > php手册 > PHP获取当前日期前30天的日期列表的应用

PHP获取当前日期前30天的日期列表的应用

WBOY
Release: 2016-06-13 09:33:16
Original
1644 people have browsed it

   最近由于项目要求做一个统计功能,统计当前日期之前的前30天的记录。功能挺简单,下面将本次实现的方法和大家分享一下,方便有需要的朋友们。

  其实主要就是用到了php的strtotime这个函数,strtotime('n day'),示例如下:

  $days=array();

  for($i=0;$i

  $days[]=date("Y-m-d",strtotime('-'.$i.'day'));

  }//http://www.Alixixi.com/php-function/970.html

  echo '

  ';print_r($days);

  结果将显示如下:

  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

  )

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template