【发布时间】:2016-01-24 12:17:03
【问题描述】:
我想像在 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 中
1.05.2016.
有人知道如何解决这个问题吗?
【问题讨论】:
-
你应该说一下你正在使用的语言和系统...
标签: php yii2 getdate leap-year