Need to create blank invoice order using xmlrpc in php

I’m submitting an order form using xmlrpc api in php in which I want to create blank order invoice to which one of the argument is to add orderdate but I’m getting error of datetime type that is it has to be of type datetime.

I’ve used the following code to set type to datetime but it fails.
$params = date(“Ymd\TH:i:s”, time());
xmlrpc_set_type($params, ‘datetime’);

any help will be appreciated. Thanks in advance.

Probably need to see your entire payload or at least some of the php. There are other params required and if you aren’t sending them or they are out of order you could get this error.

Here is the complete code that I used for it
$params = date(“Ymd\TH:i:s”, time());
xmlrpc_set_type($params, ‘datetime’);
$ordername = “Card Order”;
$leadAffiliateID = 0;
$saleAffiliateID = 0;

$call4 = new xmlrpcmsg(“InvoiceService.createBlankOrder”, array(
php_xmlrpc_encode($key),
php_xmlrpc_encode($conID),
php_xmlrpc_encode($ordername),
php_xmlrpc_encode($params),
php_xmlrpc_encode($leadAffiliateID),
php_xmlrpc_encode($saleAffiliateID)
));
$addBlankorder = $client->send($call4);

had added all the required parameters as needed.

For DateTime, try these lines of code
$dArray=date_parse(date(‘Y-m-d H:i:s’));
$tStamp = mktime($dArray[‘hour’],$dArray[‘minute’],$dArray[‘second’],$dArray[‘month’],$dArray[‘day’],$dArray[‘year’]);
$infusionDate = date(‘Ymd\TH:i:s’,$tStamp);
php_xmlrpc_encode($infusionDate);

Also, for $conID, $leadAffiliateID and $saleAffiliateID cast to (int).

So your code should look like

$ordername = “Card Order”;
$leadAffiliateID = 0;
$saleAffiliateID = 0;
//Date Formatting
$dArray=date_parse(date(‘Y-m-d H:i:s’));
$tStamp = mktime($dArray[‘hour’],$dArray[‘minute’],$dArray[‘second’],$dArray[‘month’],$dArray[‘day’],$dArray[‘year’]);
$infusionDate = date(‘Ymd\TH:i:s’,$tStamp);

$call4 = new xmlrpcmsg(“InvoiceService.createBlankOrder”, array(
php_xmlrpc_encode($key),
php_xmlrpc_encode((int)$conID),
php_xmlrpc_encode($ordername),
php_xmlrpc_encode($infusionDate),
php_xmlrpc_encode((int)$leadAffiliateID),
php_xmlrpc_encode((int)$saleAffiliateID)
));
$addBlankorder = $client->send($call4);

Yes I tried your code and I got the infusionDate value as 20200929T13:13:260
I checked by printing $call4 variable and it shows that infusionDate goes as ‘string’ type in array instead of ‘datetime’ type which is required one.

and got the error as
[errstr] => No method matching arguments: java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer

Well, for String to Date, you can use any standard PHP function of Date Class to convert into a Date Object. That should work, I believe.

yes we do have functions to convert string to date but I need to change type into datetime like int, string., Thanks.