我想像在 Facebook 上一样进行注册。有 3 个下拉列表,我可以在其中选择年、日和月。我完成了 3 个返回我的函数(从 1915 年至今的 31 天、12 个月和几年)。现在我在解析字符串时遇到了一个问题。这是我的代码:
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');
}
例如,当我采取
2016 年 2 月 31 日
. 在我的数据库中,此代码保存日期
2016 年 3 月 2 日
. 我想也许我应该比较我的日期,当用户单击 2016 年 2 月 31 日时,某些功能应该将此日期与最终日期进行比较,并返回该日期不存在的消息。单击时查看下一个示例的日历
31.04.2016
这个日期不存在,我的代码保存在 base
2016 年 5 月 1 日。
任何人都知道如何解决这个问题?