i have 3 variables with 3 numbers (day, year, month)
they all become together to a date type variable.
also, i have a date variable with the current day.
how do i check if the first date is 13 or less years before the current one?
here’s my code:
$usersday = (int)$_POST['day'];
$usersyear = (int)$_POST['year'];
$usersmonth = (int)$_POST['month'];
$takedate = date_create("$usersyear-$usersmonth-$usersday");
$date = date_format($takedate, 'd-m-Y');
$currentDate = date('Y-m-d');
2
Answers
date_*()
functions anddate()
are, confusingly, parts of two different Date library APIs. The the object-oriented version ofdate_*()
functions clarifies it a bit, as well as being a more robust library. Eg:Output
Ref: https://www.php.net/manual/en/book.datetime.php
I don’t about knowdeg php. But it will work to compare the data: