Home » Php » Datetime parameter in PHP SOAP call using the SoapClient class

Datetime parameter in PHP SOAP call using the SoapClient class

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’ve developed a PHP SOAP call with code bellow with datetime parameter.
Problem is that it displays “No Items found” if there is only one item, after the given time.
When i make the call for longer period, it shows all items accordinly.

Blockquote

Current DateTime is : 02-18-2020 13:46:20

Display products after DateTime : 02-18-2020 13:40:00

No Items found
No Items found
No Items found
………..

Thanks in advance for the help.

 <?php

echo "Current DateTime is : " . date("m-d-Y H:i:s") . "<br/><br/>";
// $dateTime = date('m-d-Y H:i:s',strtotime('-40 minutes'));

$dateTimeCall = '02-18-2020 13:40:00' ;

echo "Display products after DateTime : " . "<b>" . $dateTime . "</b>" .    "<br/><br/>";

$soap_client = new SoapClient('http://.......    /eCommerceWebService.asmx?WSDL') ;
$params = array('SiteKey' => 'qwerty',
            'Date' => $dateTimeCall,
            'StorageCode' => '11111' ) ;

 //     GetProducts 
 $response = $soap_client->GetProducts($params) ;
 $all_products = $response->GetProductsResult->StoreDetails ;

 foreach( $all_products as $product ) {

$ItemId = $product->ItemId;
$model = $product->ItemCode;
$ItemDateModified = $product->ItemDateModified;

// echo $ItemId . " - " . $model . " - " . $ItemDateModified . "<br/>";

$date = date_create($ItemDateModified);
$dateTime = date_format($date, 'm-d-Y H:i:s');

if ($ItemId) {
echo $ItemId . " - " . $model . " - " . $dateTime . "<br/>";
}
else {
echo "No Items found " . "<br/>";
}
}

 ?>
How to&Answers: