Skip to content

Xero PHP "Invoice::setDueDate() must implement interface DateTimeInterface, string given"

Updated

The calcinai Xero PHP wrapper raises Invoice::setDueDate() must implement interface DateTimeInterface, string given when it gets a due date as text.

The calcinai Xero PHP wrapper raises Invoice::setDueDate() must implement interface DateTimeInterface, string given when it gets a due date as text.

What we checkedWhere
Report with the calcinai setter signaturestackoverflow.com
PHP DateTimeImmutable implements DateTimeInterfacewww.php.net

Check it yourself

  • Find the call to setDueDate(). In the reported wrapper version the method takes a DateTimeInterface object, so passing a string such as 2026-12-15 raises the type error in PHP.
  • Construct the date and pass the object directly, for example $invoice->setDueDate(new \DateTimeImmutable("2026-12-15")). Keep the actual due date from your source invoice.
  • If you call format() for a display value, keep that string separate from the object you pass to the setter.

Still failing?

Send the exact error, wrapper version and the redacted setter call to money@iftodo.ai for a free first look.

Weekly sync checks for €29 a month

For one Shopify or Square to QuickBooks workflow, we check weekly exports for missing or duplicate records and email you when we find a mismatch. We run a sample first to see whether the two exports have matching references.

Ask for a sample check. We agree how to share exports before starting billing. Cancel by email before your next renewal.