1,105,534 Community Members

new Date() dispalys invalid date

Member Avatar
code_rum
Junior Poster in Training
80 posts since Feb 2013
Reputation Points: 8 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 6 [?]
 
2
 

Here is my code:

$(document).ready(function () {
    $(".submit-text").click(function () {

         var startdate = $("#startdate").val(); /*This line returns mm/dd/yyyy */
         var starttime = $("#starttime").val(); /*This line retruns hr:min AM/PM */

         var dtstart =  new Date("startdate" + starttime);
         alert(dtstart);
     });
    });

****On alert it displays invalid date...         

but if I use..  

var dtstart =  new Date("02/14/2013 " + starttime);

It alerts proper result...I am not getting what is wrong with this...need help

Thanx in advance

Member Avatar
code_rum
Junior Poster in Training
80 posts since Feb 2013
Reputation Points: 8 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 6 [?]
 
0
 

I got it...
In new Date() we can only pass string and not variable..
d =startdate + " " + starttime;
var dtstart = new Date(d);

:-)

Question Self-Answered as of 1 Year Ago
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: