JavaScript Date () returns invalid date

I am working on a website that will return time from a specific date. But when I call new Date()with the parameters entered by the user, it returns "Invalid date".

Here is the code I'm using: http://jsfiddle.net/8VkBu/ (CSS looks a bit weird in a small window)

Why does it return "Invalid date" and how to fix it?

Thanks, Fjpackard.

+4
source share
1 answer

I am updating JS FIDDLE

Please check..

your code should follow ...

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

instead

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

html

jquery

, html "" , jquery ""

+3

Source: https://habr.com/ru/post/1525543/


All Articles