如何从特定日期开始,获取2年后的日期?

huangapple go评论75阅读模式
英文:

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'));

See https://www.php.net/manual/en/function.strtotime.php.

huangapple
  • 本文由 发表于 2023年7月10日 21:14:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76654123.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定