I have a query:

$query->select( $db->quoteName(

    $query->join('LEFT', '#__receipts_payment_detail AS b ON b.idfkpayment_detail = a.id');
    $query->join('LEFT', '#__order_reminder_sent AS c ON a.id = c.orderref');
    $query->where($db->quoteName('a.receipt_patient_id') . ' = '.$idAuto);

this works when I substitute a value for $idAuto like 2150 or similar. However if I set the value of idAuto in code then it throws an error.

 **Call to a member function format() on bool**

I've tried lots to fix but don't understand why it works with a value as opposed to a variable.

Any ideas?

  • The error isn't coming from any code you posted. Inspect the stack trace and post the relevant code.
    – Sharky
    Commented Apr 2 at 18:35
  • Thanks @Sharky I wasn't concentrating and tried to format the returned date object wrongly in the next line of code: $date = DateTime::createFromFormat('Y-m-d H:i:s',$smsdetail->smsorderdatesent)->format('d-m-Y H:i:s'); which was throwing the error Commented Apr 3 at 10:49
  • 1
    Can you please post your comment as the Answer and then accept your Answer so that the question doesn't look like it is unresolved. You may also consider updating your original question with the code snippet that was failing and perhaps reflect the real issue in the question title to help others researching their own similar issue in the future.
    – Irata
    Commented Apr 3 at 23:56

1 Answer 1


It was the next line which was wrong

$date = DateTime::createFromFormat('Y-m-d H:i:s',$smsdetail->smsorderdatesent)->format('d-m-Y H:i:s');

Fixed and it worked like a charm

  • The question body does not contain $smsdetail so this answer is very disconnected from the question. Please edit the question to show how you declare the result from the database and then your flawed attempt to reformat the datetime stamp. Commented May 21 at 23:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.