Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6181745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:04:47+00:00 2026-05-24T01:04:47+00:00

I want to adding a time with current time using javascript…. Easiest to set

  • 0

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….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:04:48+00:00Added an answer on May 24, 2026 at 1:04 am

    a LOT of issues with your code. I am posting an answer for formatting and to understand the code

    This is not needed

     } else {
        $new_time = $new_time;
        $new_date = date('d');
     }
    

    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

    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');
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want update a column by adding days to current time. In pseudosyntax it
I want to insert current time in database using mySQL function NOW() in Codeigniter's
Using NHibernate ICriteria and adding .AddOrder ... I want to sort by a property
I want to add the current date/time to an XML document So i use
I want to use a MKMapView to display the user current location using the
I want to calculate an oscillating offset value based on the current time in
Basically, I want to continue adding numbers each time the file already existed. So
I want to update a column by adding a new value alongside the old
I am adding items to a ListBox like so: myListBox.Items.addRange(myObjectArray); and I also want
I have a SVG file that I want to extend by adding onclick handlers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.