```
 <input type="text" name="tgl_lahir" id="ttl" class="datepicker">
 Usia : &nbsp;&nbsp;<input type="text" name="usia" id="usia">

<script>
$(function() {
  $( "#ttl" ).datepicker();
});

window.onload=function(){
  $('#ttl').on('change', function() {
        var dob = new Date(this.value);
        var today = new Date();
        var age = Math.floor((today-dob) / (1000 * 60 * 60 * 24 * 360));
    $('#usia').val(age);
  });
}
</script>

```

Can't convert age in field "usia", if i run the display Nan.. if i select date 21-30 .. but if i select date 1-10 its working   

Maybe the date, can't convert, may you know to convert it ..   

Thank you