2016-09-14 1 views
-1

나는 현재를 가지고 있습니다. 3 일 후 날짜 찾기. 내가 CodeIgniter를 내 컨트롤러를 사용하고 것은 -3 일 후에 데이트를 찾는 방법

public function index() 
{ 
    date_default_timezone_set('Asia/Kolkata'); 
    $Curr_Date = date('Y/m/d'); 
    $today_dt = new DateTime($Curr_Date); 
} 
+0

체크 아웃을 [수정] (사용할 수 있습니다 http://php.net/manual/en/datetime.modify.php : 당신은 DateTime 클래스를 사용하여이 작업을 수행 할 수 있습니다) 메서드를 호출합니다. –

+0

나는 그 스레드가 6 세 이상이고 구식 방법을 보여주기 때문에 복제본에 동의하지 않습니다. 맨 아래에서만 권장되는 방법, 즉 DateTime의'add()'메소드를 발견 할 수있다. – ChristianF

+0

죄송합니다 Shaktimaan. – devendra

답변

1
$newDate = new DateTime(strtotime("+3 days")); 

난이 당신을 도울 수있다 생각 ... 꽤 똑바로 앞으로

+0

수정 된 텍스트보기, 내가 쓰는 첫 번째 텍스트는 아닙니다. –

0

.

public function index() 
{ 
    date_default_timezone_set('Asia/Kolkata'); 
    $today_dt = new DateTime(); 
    $in3days = new DateTime(); 
    $in3days->add(new DateTimeInterval("PD3")); 
} 

또는 strtotime

$in3days = new DateTime(strtotime("+3 days")); 
관련 문제