How to calculate the cycle output interval of 1 hour-php Tutorial

Source: Internet
Author: User
For example, I want to print the cyclic output at intervals of one hour every one hour from on January 1, May 25, 2013 to on January 1, June 1, 2013. That is, 5-25 & nbsp;-25 & nbsp;-25 & nbsp ;...... Thank you for your guidance! How to calculate the interval of one hour for cyclic output
For example, I want to print the output cyclically from, January 1, to, every one hour. That is
5-25
5-25
5-25
......
Thank you for your guidance!

Share:


------ Solution --------------------
$ Start = '2017-5-25 21:00:00 ';
$ End = '2017-6-1 21:00:00 ';
$ H = (strtotime ($ end)-strtotime ($ start)/3600;
For ($ I = 0; $ I <= $ h; $ I ++ ){
Echo date ("m-d H: I", strtotime ("$ start + $ I hours ")).'
';
}

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.