I need to get the value corresponding to the year of a <input type="date">
and subtract from the current date, to display the age of a user (javascript). However, my result always gives "NaN". How do I solve it? And how do I get JS itself to fetch the date (such as PHP's date("Y")
fault)?
var data = parseInt($('input[id=nasc]').val());
var ano = 2017;
var idade = ano - data;
localStorage.setItem("diaNasc", idade);