Why iphone skips the check for age?

Can't understand why iphone does not take into account the condition and android account.
I have the following test age
var bDay = ""+yearVal+"-"+monthVal+"-"+dayVal+"";
var checkAge = Math.floor((new Date().getTime() - new Date(bDay)) / (24 * 3600 * 365.25 * 1000));
if(checkAge < 18) {

The only problem on the iPhones, he skips this test and goes on, what could it be ?
June 5th 19 at 21:33
1 answer
June 5th 19 at 21:35
a) To avoid neponyatok with the date format of the input string, substitute the parameters explicitly:
new Date(yearVal, monthVal, dayVal)
b) Another useful lead time to a single value for comparison:
(new Date()).getTime() - (new Date(yearVal, monthVal, dayVal)).getTime()

PS: actually, age should be considered for each component of the date, so as not to run into leap year:
var now = new Date();
var age = (now.getFullYear() - yearVal - ((now.getMonth() - (monthVal - 1) || now.getDate() - dayVal) < 0 ? 1 : 0));
And even better to use moment for dates) - Cynthia.Donnelly commented on June 5th 19 at 21:38
If this is the only case in the project where you need to work with dates, then for the sake of spikelets processor should not start. - jerrold_Hickle commented on June 5th 19 at 21:41

Find more questions by tags iPhoneJavaScriptjQuery