PHP得到某段时间区间的时间戳 php定时任务_php实例
Jun 07, 2016 pm 05:25 PM这两天要实现这样功能:
当达到某一条件时,让服务器发短信给用户,数量为多条。
基本思路:linux 定时扫描,若有满足条件的用户,则发送短信。
但为了防止打扰到用户,要求只能在白天8:00-20:00发送短信,怎么样获得到每天的这段时间区间?
请看
$y=date("Y",time());
$m=date("m",time());
$d=date("d",time());
$start_time = mktime(9, 0, 0, $m, $d ,$y);
$end_time = mktime(19, 0, 0, $m, $d ,$y);
$time = time();
if($time >= $start_time && $time {
// do something....
}

Hot tools Tags

Hot Article

Hot tools Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Do you know some reasons why crontab scheduled tasks are not executed?

ThinkPHP6 scheduled task scheduling: scheduled task execution

Golang time processing: How to convert timestamp to string in Golang

Python implements automatic page refresh and scheduled task function analysis for headless browser collection applications

How to use PHP to develop a scheduled refresh function for web pages

Best Practices for Timestamp Obtaining: A Powerful Tool in Golang Programming

How to use scheduled tasks in FastAPI to perform background work

How to implement scheduled tasks and periodic tasks in FastAPI
