Is it possible to change the data type from String to Date

I am having problems when I encode a connection using the OpenX API with XML-RPC2. I am having a problem with the fact that the data function is the date function - DateTime.iso8601.

This is my code:

$sdatetime = new DateTime('2013-01-01 00:00:00');
$edatetime = new DateTime('2013-06-01 00:00:00');

$startDate = $sdatetime->format(DateTime::ISO8601);
$endDate = $edatetime->format(DateTime::ISO8601);

try {
    $result = $aClient->agencyPublisherStatistics($sessionId, 1, $startDate, $endDate);
    print_r($result);
} catch (XML_RPC2_FaultException $e) {
    die('Exception #' . $e->getFaultCode() . ' : ' . $e->getFaultString());
}

This is the result error when I run the script above:

Exception No. 3: parameters passed to the method are incorrect: Wanted dateTime.iso8601, received a line in param 3

If I run print_r(gettype($startDate));, I get data of type string not date .

My question is for variables $startDateand $endDatehow to make them a data type dateTime.iso8601or datenot string.

Thank.

+5
source share
3 answers

, PublisherStatistics XML_RPC2_Value. , .

$startDate = XML_RPC2_Value::createFromNative($startDate, ‘datetime’);

.. , .

+1

,

$sdatetime = date(DATE_ISO8601, strtotime('2013-01-01 00:00:00'));
$edatetime = date(DATE_ISO8601, strtotime('2013-06-01 00:00:00')); 

,

http://pear.php.net/manual/en/package.webservices.xml-rpc2.client.php

https://bugs.php.net/bug.php?id=51950

.

+1

use DateTime::setISODate

$sdatetime = new DateTime('2013-01-01 00:00:00');
$edatetime = new DateTime('2013-06-01 00:00:00');

$startDate = $sdatetime->setISODate(2013);
$endDate = $edatetime->setISODate(2013);
0
source

All Articles