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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:10:29+00:00 2026-06-05T11:10:29+00:00

I have two arrays ( i made them from jQuery from a table), the

  • 0

I have two arrays ( i made them from jQuery from a table), the first is the end date, and the second is the start date. The elements are strings:

["June, 2012", "June, 2012", "August, 2011", "April, 2013", "August, 2010", "August, 2010", "April, 2013", "April, 2012", "April, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012", "June, 2012"]

["November, 2011", "April, 2012", "May, 2008", "May, 2007", "November, 2007", "May, 2007", "June, 2006", "June, 2007", "April, 2006", "January, 2008", "April, 2001", "April, 2001", "April, 2006", "April, 1998", "April, 1998", "September, 2008", "August, 2010", "August, 2009", "August, 2010", "August, 2009", "August, 2010", "August, 2010", "August, 2010", "January, 1997", "January, 1997", "January, 2010", "January, 2007", "April, 2010"]

I am trying to get the elapsed time between each set of indices. I would assume that I have to convert these strings to a Date Object date() then do the calculation to get the elapsed time, then truncated it to just the month and year using something like this:

function convertDate(passedDate) {
    var m = new Array(7);
    var y = passedDate.getFullYear();
    m[0] = "January";
    m[1] = "February";
    m[2] = "March";
    m[3] = "April";
    m[4] = "May";
    m[5] = "June";
    m[6] = "July";
    m[7] = "August";
    m[8] = "September";
    m[9] = "October";
    m[10] = "November";
    m[11] = "December";
    return m[passedDate.getMonth()] + "months and " + y + " years;  
};

Here is the fiddle and here are my questions:

  1. Is there anyway to do this without changing it to a date object, since I’m not interested in the days or time?

  2. Is there another approach you would suggest than trying to convert to date for the elapsed date math formula, then converting back to a string?

  3. How would I identify the sister elements of the current element, so that I could avoid using a double nested loop? ( will also ask this in a different question since it addresses a different topic)

Thanks for helping me, as I’m trying to make an interactive resume with selectable attributes, and I’m including some data so I don’t have to answer all the basic information to recruiters who cold call.

  • 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-05T11:10:31+00:00Added an answer on June 5, 2026 at 11:10 am

    Really, all you need is a map from month names to numbers. You can build one like this:

    var monthNames = [ "January",   "February", "March",    "April",
                       "May",       "June",     "July",     "August",
                       "September", "October",  "November", "December" ]
    var monthNumber = {}
    for (var i=0; i<monthNames.length; ++i) {
        monthNumber[monthNames[i]] = i;
    }
    

    Now you have, e.g., monthNumber['October'] == 9. Then you can turn one of your strings into a month number and year. If you then turn that into an absolute month number (year * 12 + month), you can just subtract to get the elapsed months.

    function stringToMonthNumber(monthYear) {
        var parts = monthYear.split(/\s*,\s*/)
        var month = monthNumber[parts[0]]
        var year = parts[1] - 1
        return year * 12 + month
    }
    
    function elapsedMonths(startString, endString) {
        return stringToMonthNumber(endString) - stringToMonthNumber(startString)
    }
    

    Then this:

    elapsedMonths("November, 2011", "June, 2012")
    

    returns 7.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays with time values in them in this format. 00:00:00 which
I have two arrays of values like X,Y,Z and 1,2 There is a table
I have two arrays (a and b) with n integer elements in the range
I have two arrays. I'd like to merge them into one, but remove the
I have two arrays, one that is made up of NSDates and one that's
Assume I have two strings (or byte arrays) A and B which both have
i want two arrays first one of all subjects and the second of all
I have two arrays, one is very large (more than million entries) and other
I have two arrays that I would like to compare and ultimately wind up
I have two arrays: Walls and Neighbors. public boolean[] walls = new boolean[4]; public

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.