2012-12-12 27 views
-2

我有开始日期(timestamp)和结束日期(timestamp)的MySQL列和paid_period(3个月或6个月)的第3列,我想要3个月(paid_period)全期差异。根据设定的时间段来确定日期

示例开始日期是1-jan-2012并且结束日期是1-jan-2013。我想要3个月的时间, like 1st installment goes on 1-mar-2012 ,2nd on 2012年6月1日等等。

我该怎么办?

+1

[你尝试过什么?](http://www.whathaveyoutried.com/)请参阅[常见问题](工作http://stackoverflow.com/faq ), 请。 –

回答

2

DateTime使得使用日期容易

$date = new DateTime('1-jan-2012'); // Start date 
$date->modify('+3 months');   // 3 months later 
echo $date->getTimestamp();   // timestamp 
$date->modify('+3 months');   // 6 mnths later 
echo $date->getTimestamp();   // timestamp 
$date->modify('+3 months');   // 9 months later 
echo $date->getTimestamp();   // timestamp 
相关问题