英文:
How to get the date after 2 years starting from a particular datetime?
问题
MySql数据库中有一个datetime列,例如 2022-11-25 11:15:49
。如何获取此日期之后的2年日期?未来日期的时间将为23:59:59,但最重要的是持续时间,即2年。
英文:
There is a datetime column in the MySql database, say 2022-11-25 11:15:49
. How can I get the date in 2 years after this date ? The times of the future date will be 23:59:59, but the duration is the most important which is 2 years.
答案1
得分: 2
在PHP中(如此标记),$date = date('Y-m-d H:i:s', strtotime($row['datefield'] . ' +2 years'));
请参考https://www.php.net/manual/en/function.strtotime.php。
英文:
In PHP (as this was tagged) $date = date('Y-m-d H:i:s', strtotime($row['datefield'] . ' +2 years'));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论