I want to do my registration like in Facebook. There is 3 dropdownlist where I choose year, day and month. I finished 3 function which return me (31 days, 12 months and years from 1915-today). Now I have one problem when I parse string to date. This is my code:
public function getDate() {
$month = $this->Month;
return $this->Year . '-' . $month . '-' . $this->Day;
}
public function getDbFormatedDate() {
$dateDeadline = date_create($this->getDate());
return date_format($dateDeadline, 'Y-m-d');
}
for example when I take
31 February 2016
. In my database this code save date
2 March 2016
. I think maybe I should compare my dates and when user click 31 February 2016 some function should compare this date with final date and return message that this date does not exist. Look at calendar for next example when I click
31.04.2016
this date doesn't exist and my code save in base
1.05.2016.
Anyone have idea how to resolve this?