从MySQL添加到PHP的当前日期 [英] Add days to current date from MySQL with PHP
本文介绍了从MySQL添加到PHP的当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个固定的日期从MySql
I have a fixed date from MySql
startDate = 07/03/2011
我想在此日期之前添加60天以获得endDate。
I wanted to add 60 days on top this date to have an endDate.
$startDate = $result['startDate'];
$endDate = ??? + strtotime("+60 days");
echo $endDate;
从我的研究中,我知道它与strtotime有关,但我遇到的所有网站根据当前工作站的时间开始日期。我的日期已经固定并在运行之前输入并获得endDate。
From my research, I know it has something do with strtotime, but all the sites I come across with based the start date from current workstation's time. My date is already fixed and entered prior to running and getting the endDate.
帮助?提前致谢!
推荐答案
除了别人提供的PHP解决方案之外,您还可以创建 endDate
在MySQL内部,并保存自己一些麻烦:
In addition to PHP solutions others are providing, you can create the endDate
right inside of MySQL and save yourself some of the trouble:
SELECT startDate, DATE_ADD(startDate, INTERVAL 60 DAY) AS endDate FROM table;
-- Or by months (not exactly the same thing)
SELECT startDate, DATE_ADD(startDate, INTERVAL 2 MONTH) AS endDate FROM table;
这篇关于从MySQL添加到PHP的当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文