Date Difference (datediff)

private function check_date_duration($limit, $from, $to){
	$datetime1 = new DateTime($from);
	$datetime2 = new DateTime($to);
	$interval = $datetime1->diff($datetime2);
	$duration = $interval->format('%a') + 1;
	//log_g($limit);

	if($duration < $limit){
		$this->failed_response(0, '合約天數小於系統設定最小值: ' . $limit . '天');
	}
}

Reference: