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 8554275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:50:41+00:00 2026-06-11T14:50:41+00:00

I am trying to fill an array/list with values from a time subtraction. I

  • 0

I am trying to fill an array/list with values from a time subtraction. I have start time in this format “09.00 AM” and End time in the same format ex: “06.00 PM”, both times are coming from two drop downs (values from 9 am to 9 pm with hourly increments) which are actually jquery time picker controls. This is what I am trying to do.. after user selects both times, I want to populate an array/list with individual “hour” mark values that fall between the two selected time values. For ex: selecting 9 am and 12 pm should give me values { “10.00 AM”, “11.00 AM”}.. selecting 10 AM to 4 PM should give me {“11.00 AM”, “12.00 PM”, “01.00 PM”, “02.00 PM”, “03.00 PM”}..

var FirstTime = container.find('#1time').val();
var SecondTime = container.find('#2time').val(); 

var busyTimes = [];
busyTimes =  getBusyTimes(FirstTime , SecondTime);

Function js:

function getBusyTimes(first, second) {
    var f = first.split(' '), s = second.split(' ');
    if (first == '12.00 AM') f[0] = '0';
    if (first == '12.00 PM') f[1] = 'AM';
    if (second == '12.00 AM') s[0] = '24';
    if (second == '12.00 PM') s[1] = 'AM';
    f[0] = parseInt(f[0], 10) + (f[1] == 'PM' ? 12 : 0);
    s[0] = parseInt(s[0], 10) + (s[1] == 'PM' ? 12 : 0);
    int i = s[0] - f[0];
    // I have difference in hours in "i"
    //From here, I want to make use of value 'i' -- calculate in between   
    // hourly values and return the array back to 
    // original function above.
}
  • 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-06-11T14:50:42+00:00Added an answer on June 11, 2026 at 2:50 pm

    I have not tested this but it should work for what you are trying to do and it should operate faster than the calculations you are trying to do.

    function getBusyTimes(first, second){
    var timeList = ['12:00 AM','1:00 AM','2:00 AM','3:00 AM']; // finish this list
    var firstid  = timeList.indexOf(first);
    var secondid = timeList.indexOf(second);
    var result = new Array();
    for(var i=firstid; i<=secondid; i++ ){
        result.push(timeList[i]);
    }
    return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fill out an array with values from checkboxes. It works just
I'm trying to fill an array of 20 ints with numbers from 1-20 in
I am trying to fill a RealVector (from Apache Commons Math) with values. I
I am trying to remove an object from an array and fill the slot
I'm trying to output a list from an SQLite database and am getting this
I am trying to Fill a formula that I have in D1 and fill
I am trying to fill object[] with List<string> but I cannot figure out how
I am trying to fill my view model with some drop down options from
i am trying to load the list of items from arrays... i get runtime
I am trying to simulate a click event on list items with the same

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.