PHP gets a list of dates 30 days before the current date _php tutorial

Source: Internet
Author: User
Recently, due to the project requirements to do a statistical function, statistics before the current date of the first 30 days of records. function is very simple, the following will be the implementation of the method and everyone to share, convenient for the needs of friends.

In fact, the main use of PHP strtotime this function, Strtotime (' N Day '), the example is as follows:

$days =array (); for ($i =0; $i <=7; $i + +) {//Here the number varies according to need $days[]=date ("y-m-d", Strtotime ('-'. $i. ' Day '));} Http://www.phpernote.com/php-function/970.htmlecho '
';p rint_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 PHP gets a list of dates over a period of time
    • PHP to add a backslash in front of the reason and PHP to remove the backslash method, three ways to close the PHP magic quotes
    • JavaScript gets the current datetime and displays the day of the week
    • PHP gets the week of the specified date, the first day of the month, and the last day
    • PHP calculates the number of days (day) of a two-date function
    • PHP gets the timestamp of the start time and end time of the week of the specified date
    • Php method for retrieving Ganzhi, Zodiac and constellation information based on date or time stamp
    • PHP Extract the birthday date from the ID number and the function to verify whether it is a minor

http://www.bkjia.com/PHPjc/764087.html www.bkjia.com true http://www.bkjia.com/PHPjc/764087.html techarticle recently, due to the project requirements to do a statistical function, statistics before the current date of the first 30 days of records. function is very simple, the following will be the implementation of the method and everyone to share a bit, convenient to have the need ...

  • 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.