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 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
  • 1 View
  • 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 float values, 'a' and 'b' . I need to calculate the
I have two Perl string variables containing date values. I want to check whether
I have the following array coming from a form submission: Array ( [id0] =>
I have some values coming from a datasource that I have control over. I
Dictionary cannot have two values with same key. please tell which logic/algorithm being used
I have two integer values, x and total. I am trying to find the
I have two arrays of values like X,Y,Z and 1,2 There is a table
i have database with two values id and val so i want to ask
I have tracked two event values customReport1 and CustomReport 2 using GA event tracking
I have two arrays with time values in them in this format. 00:00:00 which

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.