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

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

Jun 13, 2016 am 09:33 AM
phpDolistFunctionapplicationdateofstatisticsObtainRequireproject

   最近由于项目要求做一个统计功能,统计当前日期之前的前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

  )

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools