Strtotime-php Tutorial

Source: Internet
Author: User
For the strtotime issue, I 'd like to think of a loop, that is, a day is automatically subtracted from each cycle based on the current date, such as PHPcodefor ($ i0; $ I & lt; 10; $ I ++) {$ current_datedate (& quot; Y-m-d & quot;, strtotime (& quot;-$ iday & quot ;));} this does not seem to work! I want to automatically generate a current date to solve the number of strtotime problems.
Ladies and gentlemen
I want to get a cycle, that is, according to the current date, each cycle is reduced by one day, for example
PHP code
  For ($ I = 0; $ I <10; $ I ++) {$ current_date = date ("Y-m-d ", strtotime ("-$ I day "));}


This does not seem to work!
I want to automatically generate a current date to facilitate data query in the database by date.
Or do you have any other solutions?

Thank you!

------ Solution --------------------
PHP code
/* No problem. 2012-02-282012-02-272012-02-262012-02-02-252012-02-242012-02-02-232012-02-222012-02-212012-02 -202012-02-19 */for ($ I = 0; $ I <10; $ I ++) {$ current_date = date ("Y-m-d", strtotime ("-$ I day"); echo $ current_date.'
';}

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.