dtbiszu7724 2016-07-11 22:56
浏览 22

计时器将在凌晨4点或下午4点停止

I have created a timer that will stopped at 4:20 am/pm till 4:29 am/pm The main problem I am having is when the time will be greater then 4 or less then 17 how i will set a logic there I am pretty much confused I tried a logic but this is not working for me the time is not showing then. Like if hours will be greater then 12 like 12 13 14 then how will i get the time difference or when the timer will resume at 16:29 how will i get the difference from 16:29 to 4:20 ??

<?php 
require('../config/connection.php');

$last_time = $_POST['time_last'];
$cr_time   = $_POST['cr_time']; 
$cur_time  = explode(':', $cr_time);
$last_time--;

$minutes = array('20', '21', '22', '23', '24', '25', '26', '27', '28', '29');

if($cur_time[0] == '4' || $cur_time[0] == '16') {
    if(in_array($cur_time[1], $minutes)) {
        $update = mysqli_query($connection, "UPDATE timer SET time_start = '0' WHERE id = '1'");
        echo '0';
    } else {
        $update = mysqli_query($connection, "UPDATE timer SET time_start = '0' WHERE id = '1'");
        echo '0';
    }
} else {
    if($cur_time[0] > '4' || $cur_time[0] < '17') {
        $differenceInhour =  strtotime('16:20:00') - strtotime($cr_time);
    }
    if($cur_time[0] >= '17' || $cur_time[0] <= '23') {
        $differenceInhour =  strtotime('23:59:00') + 14400 - strtotime($cr_time);
    } 
    if($cur_time[0] > '23' || $cur_time[0] <= '4') {
        $differenceInhour =  strtotime('4:20:00') - strtotime($cr_time);
    } 
    $update     = mysqli_query($connection, "UPDATE timer SET time_start = '$differenceInhour' WHERE id = '1'");
    echo $differenceInhour;
}

?>

Please help me out with this please I am only having issue when the clock will be greater then 4 how wil i now calculate the remaining time till 16 and from 16 to 4

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP