PHP: getting the date list for the first 30 days of the current date _ PHP Tutorial

Source: Internet
Author: User
PHP retrieves the list of dates 30 days before the current date. Recently, the project requires a statistical function to count the records of the first 30 days before the current date. The function is quite simple. I will share with you the implementation method below, so that you can easily make a statistical function recently due to project requirements 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 to make it easy for anyone who needs it.

In fact, the strtotime function of php is mainly used, strtotime ('N day'). The example is as follows:

$ Days = array (); for ($ I = 0; $ I <= 7; $ I ++) {// here the number is changed as needed $ days [] = date ("Y-m-d", strtotime ('-'. $ I. 'day');} // http://www.phpernote.com/php-function/970.htmlecho'
';print_r($days);

The result is 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 does PHP obtain the date list for a period of time?
  • Reasons why PHP adds a backslash before the quotation mark and how PHP removes the backslash, there are three ways to disable the php magic quotation mark
  • JavaScript retrieves the current date and time and displays the day of the week at the same time
  • PHP obtains the week of the specified date, the first day of the month and the last day of the month.
  • Php calculates the number of days of the difference between two dates.
  • Php obtains the start time and end time timestamp of the week of the specified date.
  • How to obtain information about the year, Zodiac, and Constellation of the rule by using the date or timestamp in php
  • Php extracts the birthday date from the ID card number and verifies whether it is a minor.

Bytes. The function is quite simple. I will share with you the implementation method below to facilitate your needs...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.