0
global $adb;                                

$sql = 'SELECT * from vtiger_invoice where invoiceid = ?';
 $result = $adb->pquery($sql,array($_REQUEST['record']));
 $fecha=$adb->query_result($result,$i,'invoicedate'); 

for($i=0;$i<sizeof($vencimientos);$i++)
{
$date[$i] = date_create($fecha);
date_add($date[$i], date_interval_create_from_date_string($periodicidad.' days'));
$fechafinal = explode(" ",$date[$i]->date);
$splitdate = explode("-",$fechafinal[0]);
$reversedate = array_reverse($splitdate);  
 $fechafinal = implode("-",$reversedate);                    

$pdf->MultiCell(100, $summaryCellHeight , $fechafinal, '', 'L', 0, 1, $summaryLineX+135, $summaryLineY);

$summaryLineY += 4;
}

The problem is this code dont works, or at least $fechafinal didnt get value. When im debugging, all works 100% but when i execute dont works.

I tried put 'sleeps' but dont works too.

What can i do? This is strange because i cant find error because when im debugging all works :/

2
  • when you say debbugging, what are you doing? where is $i set in this line $fecha=$adb->query_result($result,$i,'invoicedate'); Commented Feb 16, 2012 at 12:34
  • What are you trying to achieve? What does your schema data look like? And what output/end result are you expecting? Commented Feb 16, 2012 at 12:41

1 Answer 1

1

I think the problem may lie in this line:

$fechafinal = explode(" ",$date[$i]->date);

A DateTime object doesn't have any public member date so you wouldn't get any string there. What you want to use is format().

With format() You could replace these four lines:

$fechafinal = explode(" ",$date[$i]->date);
$splitdate = explode("-",$fechafinal[0]);
$reversedate = array_reverse($splitdate);  
$fechafinal = implode("-",$reversedate); 

with:

$fechafinal = $date[$i]->format('d-m-Y'); // Change the formatting to what you need.
Sign up to request clarification or add additional context in comments.

1 Comment

Pfffffffffffffffff.......... that's was amazing guy. Rly rly thanks. This works 100% perfect. Thanks again, u made my day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.