Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript添加时间_Javascript_Codeigniter_Date - Fatal编程技术网

使用javascript添加时间

使用javascript添加时间,javascript,codeigniter,date,Javascript,Codeigniter,Date,我想使用javascript添加当前时间的时间 最容易树立一个榜样。。。 e、 g 在“管理”部分中,将“最小小时预订通知”设置为12小时($minHours=12) 现在的时间是2011年7月26日10:30 我想订一辆今天17点的车 但10:30+分钟小时数input->post('time1'); $sec1=$this->input->post('sec1'); $act=$hour1.“:”$sec1; $min_hr=$this->input->post('min_hr'); $cu

我想使用javascript添加当前时间的时间

最容易树立一个榜样。。。 e、 g

在“管理”部分中,将“最小小时预订通知”设置为12小时($minHours=12) 现在的时间是2011年7月26日10:30 我想订一辆今天17点的车

但10:30+分钟小时数<17:00 因此我不能预订。然后我会收到屏幕上的弹出/通知,不允许预订

这个的PHP代码

    $hour1 = $this->input->post('time1');
    $sec1 = $this->input->post('sec1');
    $act = $hour1 . ':' . $sec1;
    $min_hr = $this->input->post('min_hr');
    $current_time = date("H:i");
    $new_date = date('d');
    $exe = explode(':', $current_time);

    $new_time = $exe['0'] + $min_hr;
    if ($new_time > 24) {
        $new_time = $new_time - 24;
        $new_date = date('d') + 1;
    } else {
        $new_time = $new_time;
        $new_date = date('d');
    }


    if($date1 > $new_date){
        if($hour1 > $new_time){
            redirect('mesage');

        }  elseif ($hour1 == $new_time) {
            if($sec1 <= $exe['1']){
                redirect('mesage');                     
            }
        }

    } elseif ($date1 == $new_date) {
        if($hour1 < $new_time){
            redirect('mesage');

        }  elseif ($hour1 == $new_time) {
            if($sec1 <= $exe['1']){
                redirect('mesage');

            }
        }
    }
$hour1=$this->input->post('time1');
$sec1=$this->input->post('sec1');
$act=$hour1.“:”$sec1;
$min_hr=$this->input->post('min_hr');
$current_time=日期(“H:i”);
$new_date=日期('d');
$exe=explode(“:”,$current_time);
$new_time=$exe['0']+$min_hr;
如果($new_time>24){
$new_time=$new_time-24;
$new_date=日期('d')+1;
}否则{
$new_time=$new_time;
$new_date=日期('d');
}
如果($date1>$new\u日期){
如果($hour1>$new\u时间){
重定向('mesage');
}elseif($hour1==$new\u时间){

如果($sec1用于javascript日期时间制作,我建议使用

它允许灵活的日期时间加减,即:

// Get today's date
Date.today();

// Add 5 days to today
Date.today().add(5).days();

// Get Friday of this week
Date.friday();

// Get March of this year
Date.march();

// Is today Friday?
Date.today().is().friday();  // true|false

// What day is it?
Date.today().getDayName();

你的代码有很多问题。我正在发布一个关于格式和理解代码的答案

这是不必要的

 } else {
    $new_time = $new_time;
    $new_date = date('d');
 }
什么是日期1

当你显然是指分钟的时候,为什么会有秒1

脚本的参数来自哪里

这是您的JS中的php

var hour1 = qs('time1'); // qs is some function that for example uses the query string
var min1 = qs('sec1'); // you do mean minutes, no?
var act = hour1 + ':' + min1;
var min_hr = qs('min_hr');
var new_date = new Date();
var hh = new_date.getHours(); 
var mm = new_date.getMinutes(); 
var ss = new_date.getSeconds(); 

var new_time = hh + parseInt(min_hr);
if (new_time > 24) {
  new_time = new_time - 24;
  new_date.setDate(new_date.getDate()+1);
}

if(date1.getTime() > new_date.getTime(){ // where did date1 come from?
  if(hour1 > new_time){
    alert("message")
  }  
  else if (hour1 == new_time &&  min1 <= mm){
    alert("message")                     
  }
} 
else if (date1.getTime() == new_date.getTime() {
  if(hour1 < new_time){
    alert('message');
  }  
  else if (hour1 == new_time && min1 <= mm){
    alert('mesage');
  }
}
var hour1=qs('time1');//qs是一些函数,例如使用查询字符串
var min1=qs('sec1');//你是说分钟,不是吗?
var act=hour1+':'+min1;
var min_hr=qs('min_hr');
var new_date=新日期();
var hh=new_date.getHours();
var mm=new_date.getMinutes();
var ss=new_date.getSeconds();
var new_time=hh+parseInt(min_hr);
如果(新时间>24){
新建时间=新建时间-24;
new_date.setDate(new_date.getDate()+1);
}
如果(date1.getTime()>new_date.getTime(){//date1来自哪里?
如果(小时1>新建时间){
警报(“消息”)
}  

否则如果(hour1==new\u time&&min1)实际问题是什么?请更具体地说明您需要什么帮助或建议。您已经说过“JavaScript”在标题中标记了问题
javascript
,但您引用了一段PHP代码。我想将此PHP代码转换为javascriptYes?那么,您当前的javascript是什么样子的?什么不起作用?