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

  • Home
  • SEARCH
  • 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 4122538
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:29:40+00:00 2026-05-20T23:29:40+00:00

I have two values coming in, a string in the form StartTime YYYY-MM-DD HH:MM:SS

  • 0

I have two values coming in, a string in the form StartTime YYYY-MM-DD HH:MM:SS and a Duration in the form HH:MM:SS. from these two values I need to determine the endTime and put it in the same format as the StartTime.

I have tried to make something like

startTimeArray:Array = StartTime.split(/[ -:]/);
var date:Date = new Date(startTimeArray[0], startTimeArray[1]-1, startTimeArray[2], startTimeArray[3], startTimeArray[4], startTimeArray[5] );

but the split of course results in strings and not numbers and I can’t figure how to convert all these sections of the time into numbers, and following that I do not see a way to apply math by adding the Duration Date object to the StartTime Date object if I am able to get them properly converted.

Am I going down a good path here? if so, how can I convert an array of strings to numbers and how can I add the duration to starttime? Thanks

  • 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-20T23:29:41+00:00Added an answer on May 20, 2026 at 11:29 pm
    const start:String = "2011-04-03 01:39:48";
    const startArray:Array = start.split(/[: -]/g);
    var startDate:Date = new Date(
        startArray[0], startArray[1]-1, startArray[2],
        startArray[3], startArray[4], startArray[5]
    );
    const duration:String = "02:10:10";
    const durationArray:Array = duration.split(/:/g);
    var durationDate:Date = new Date();
    durationDate.setTime(
        durationArray[0] * 3600000 + /* hour = 60m * 60s * 1000ms */
        durationArray[1] * 60000 + /* minute = 60s * 1000ms */
        durationArray[2] * 1000 /* second = 1000ms */
    );
    var finalDate:Date = new Date();
    finalDate.setTime(startDate.time + durationDate.time);
    trace(startDate);
    trace(durationDate.time);
    trace(finalDate);
    

    Outputs:

    Sun Apr 3 01:39:48 GMT-0300 2011
    7810000
    Sun Apr 3 03:49:58 GMT-0300 2011
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two comboboxes on an form. Each has the values Yes and No.
I am trying to compare two decimal values in Java script. I have two
If I have two variables containing binary values, how do I append them together
I have two fields in a table. One contains values such as BTA, BEA,
I have a stored procedure that returns two int Values. The first can not
I have created two forms in my Windows Application. One Form acts as a
I have two fields: string date1 = 04/26/10; string date2 = 04/25/10; How can
I'm having trouble mapping the following in NHibernate: I have two tables (these are
I have some float values I want to convert to a string, I want
I have a php form with two text boxes and i want to enter

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.