Home Backend Development PHP Tutorial PHP得到某段时间区间的时间戳 php定时任务_php实例

PHP得到某段时间区间的时间戳 php定时任务_php实例

Jun 07, 2016 pm 05:25 PM
scheduled tasks Timestamp

这两天要实现这样功能:

当达到某一条件时,让服务器发短信给用户,数量为多条。

基本思路: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....
}
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot tools Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Do you know some reasons why crontab scheduled tasks are not executed? Do you know some reasons why crontab scheduled tasks are not executed? Mar 09, 2024 am 09:49 AM

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

ThinkPHP6 scheduled task scheduling: scheduled task execution ThinkPHP6 scheduled task scheduling: scheduled task execution Aug 12, 2023 pm 03:28 PM

ThinkPHP6 scheduled task scheduling: scheduled task execution

Golang time processing: How to convert timestamp to string in Golang Golang time processing: How to convert timestamp to string in Golang Feb 24, 2024 pm 10:42 PM

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 Python implements automatic page refresh and scheduled task function analysis for headless browser collection applications Aug 08, 2023 am 08:13 AM

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 How to use PHP to develop a scheduled refresh function for web pages Aug 17, 2023 pm 04:25 PM

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

Best Practices for Timestamp Obtaining: A Powerful Tool in Golang Programming Best Practices for Timestamp Obtaining: A Powerful Tool in Golang Programming Dec 29, 2023 am 08:28 AM

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

How to use scheduled tasks in FastAPI to perform background work How to use scheduled tasks in FastAPI to perform background work Jul 28, 2023 pm 02:22 PM

How to use scheduled tasks in FastAPI to perform background work

How to implement scheduled tasks and periodic tasks in FastAPI How to implement scheduled tasks and periodic tasks in FastAPI Jul 30, 2023 pm 03:53 PM

How to implement scheduled tasks and periodic tasks in FastAPI

See all articles