I am getting an error:
Statdate.getFullyear() is not a function.
From this javascript code:
var start = new Date(); start = document.getElementById('Stardate').value ; var y = start.getFullYear();
Any idea why that function isn't available?
getFullYear() returns the full year (4 digits) of a date.
To get the current year in JavaScript, call the new Date() constructor to get a date object and call the getFullYear() method on the result, e.g. new Date(). getFullYear() . The getFullYear method will return a number corresponding to the current year.
Description. Javascript date getYear() method returns the year in the specified date according to universal time. The getYear is no longer used and has been replaced by the getYear method. The value returned by getYear is the current year minus 1900.
Try this...
var start = new Date(document.getElementById('Stardate').value); var y = start.getFullYear();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With