


PHP Get the date list 30 days before the current date_PHP Tutorial
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);
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.
