I want to adding a time with current time using javascript….
Easiest to set an example…
e.g.
In the admin section set the “Minimum Hours Booking Notice” as 12 hours ($minHours = 12)
The time now is 10:30 on 26th July 2011
I want to book a vehicle for today at 17:00
BUT 10:30 + $minHours < 17:00
THEREFORE I CANNOT make the booking. Then I should be notified by a popup/ notice onscreen and the booking should not be allowed.
PHP Code for this…..
$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');
}
}
}
Please help….
a LOT of issues with your code. I am posting an answer for formatting and to understand the code
This is not needed
what is date1?
Why do you have sec1 when you obviously mean minutes
Where will the parameters for the script come from?
Here is your php in JS