PHP automatically calculates the last day of the month to trigger a settlement or to execute a method.

Source: Internet
Author: User
function is the title, I really can not think of what way and ideas to solve, what is the best way for everyone?
Or paste the code, provide the next idea!

Reply content:

function is the title, I really can not think of what way and ideas to solve, what is the best way for everyone?
Or paste the code, provide the next idea!

The PHP script is as follows:

if (date("Y-m-t") == date('Y-m-d')) {    //Do Something;}

Configure Crontab to run the PHP script once a day.

Actually very simple, really ...

$date = new DateTime("now", new DateTimeZone('Asia/Shanghai'));echo $date->modify('last day of this month')->format('Y-m-d');

Just a little bit more about automatic triggering, automatic triggering if cron you set the script to execute once a day.

Php

set_time_limit(0);// 不是一个月最后一天, 略过if (date('d') != date('t')) {    exit(0);}// 业务逻辑  something to do

Crond

0 6 * * * * php /xxx/xxx/xxx.php

Many domestic program simulation corn, is to use JavaScript to call PHP files, in the file to determine whether to meet the implementation standards.

In other words, you must have a steady flow of requests. Others want to, ask this question probably you also can not use cron.


  
   

Related Article

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.