This is my HTML
<input type="text" class="dateofbirthpicker">
<input type="text" id="usia">
Script
$(function() {
$('.dateofbirthpicker').datepicker({
dateFormat: 'yyyy/mm/dd'
});
});
window.onload=function() {
$('.dateofbirthpicker').on('change', function() {
var dob = new Date(this.value);
var today = new Date();
var age = Math.floor((today-dob) / (1000 * 60 * 60 * 24 * 360));
ages = parseInt(age);
$('#usia').val(ages);
});
}
I have the above script to calculated age from date. It is returning age in Firefox but returns NaN
in Chrome.
I was doing this Jquery Date.parse returning NaN in Chrome browser?
Result was invalid date when i ran the following...
var dob = new Date(this.value);