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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:42:16+00:00 2026-06-08T08:42:16+00:00

I have two date variable separately like following startDate is a Date instance with

  • 0

I have two date variable separately like following

startDate is a Date instance with the value Tue Jul 17 2012 00:00:00 GMT+0530 (IST)

startTime is a String with the value "11:30 AM"

Now what I need is join of both above date & time, as a Date.

startDateTime = Tue Jul 17 2012 11:30:00 GMT+0530 (IST)

I tried

new Date(startDate + " " + startDate) but outputting invalid date.

Also tried the way shown on this post. But still not working.

  • 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-08T08:42:17+00:00Added an answer on June 8, 2026 at 8:42 am

    You can readily parse startTime if it’s in a clearly-defined format, then use setHours and setMinutes: Live example | source

    var startDateTime;
    var parts = /^(\d+):(\d+) (AM|PM)$/.exec(startTime);
    if (parts) {
        hours = parseInt(parts[1], 10);
        minutes = parseInt(parts[2], 10);
        if (parts[3] === "PM" && hours !== 12) {
            hours += 12;
        }
        else if (parts[3] === "AM" && hours === 12) {
            hours = 0;
        }
        if (!isNaN(hours) && !isNaN(minutes)) {
            startDateTime = new Date(startDate.getTime());
            startDateTime.setHours(hours);
            startDateTime.setMinutes(minutes);
        }
    }
    

    …or something along those lines.

    Note that key to this is the fact you’ve said startDate is a Date instance. The above assumes we’re working within the timezone of the JavaScript environment, not across zones. If you were starting with a date string instead, and that string specified a timezone other than the JavaScript environment’s timezone, which you were then converting into a Date via new Date("Tues Jul...."), then you’d have to be sure to adjust the resulting Date to use either the local time of the environment, or UTC; if you adjusted it to be UTC, you’d use setUTCHours and setUTCSeconds above instead of setHours and setSeconds. Again, this is only an issue if your starting point is a date string, and that string specifies a timezone different from the timezone in which the code above is running.

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

Sidebar

Related Questions

I have two date pickers one for startDate and another one is for endDate.
Let's say I have an instance variable NSDate *date; and I do (for example
I have two Perl string variables containing date values. I want to check whether
I have two date entities, start_date and end_date and now I want to find
HI i have two date pickers. datepicker1, datepicker2. I need datepicker1.date to compare with
I have two Zend Date objects to work with: $now = Zend_Date::now(); $sessionStart =
I'm using the jQuery datepicker where I have two textboxes (start date / end
I have two tables: Table_A name1 create_date Table_B name2 keep_time name1 is something like
I have two Java instances of java.util.Date and I have to find out if
I have two dates namely the filecreation date and the system date both in

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.