JavaScript Date() returns Invalid Date

css, date, html, javascript, jquery

Solution

I update your JS FIDDLE

Please check..

your code should be following...

y = parseInt($("#year").val());
m = parseInt($("#month").val()) - 1;
d = parseInt($("#day").val());
h = parseInt($("#hour").val());

instead of

y = parseInt($("#years").val());
m = parseInt($("#months").val()) - 1;
d = parseInt($("#days").val());
h = parseInt($("#hours").val());

because your input id in html form is singular form

but in your jquery you use plural form

Such as in html you use 'year' and in your jquery you use 'years'

Problem

I am working on a website that will return the time since a certain date. But when I call `new Date()` with parameters the user has inputted, it returned "Invalid Date". Here is the code I am using: http://jsfiddle.net/8VkBu/ (the CSS looks a bit weird in the small window) Why is it returned "Invalid Date", and how can I fix it? Thanks, Fjpackard.

Original source