We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,617 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

new Date() dispalys invalid date

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

1
Contributor
1
Reply
18 Minutes
Discussion Span
4 Months Ago
Last Updated
14
Views
Question
Answered
code_rum
Junior Poster in Training
73 posts since Feb 2013
Reputation Points: 8
Solved Threads: 12
Skill Endorsements: 4

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

:-)

code_rum
Junior Poster in Training
73 posts since Feb 2013
Reputation Points: 8
Solved Threads: 12
Skill Endorsements: 4
Question Self-Answered as of 4 Months Ago

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.1658 seconds using 2.64MB