2014-12-01 40 views
0

任何人都知道如何根據周/月/年計算日期?根據php/joomla中的時期計算日期

假設如果我將期限設置爲2周,我應該在當前日期後2周獲取日期。如果期限是3周,那麼我應該在當前日期之後3周。同樣的月份和年份也是如此。任何人都可以請參考代碼幫忙嗎?我無法實現這一點。 有沒有任何預定義的功能?

回答

1

我對你想要得到的東西並不十分清楚,但看看這answerjoomla.stackexchange.com查看PHP-esque日期計算是可能的。這是關於宿舍,但與strtotime使用變化,你應該能夠得到你所需要的。

$date = date("Y-m-d");// current date 

$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day"); 
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week"); 
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week"); 
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month"); 
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");