Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: getFullyear() is not a function

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?

like image 782
Prady Avatar asked Feb 08 '11 03:02

Prady


People also ask

What does getFullYear do in JavaScript?

getFullYear() returns the full year (4 digits) of a date.

How can we get the current year in JavaScript?

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.

How do you get the year from a new date?

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.


1 Answers

Try this...

 var start = new Date(document.getElementById('Stardate').value);  var y = start.getFullYear(); 
like image 64
limc Avatar answered Sep 18 '22 17:09

limc