Viewed   80 times

PHP Class DateInterval has a property "days". According to the manual it returns "Total number of days the interval spans. If this is unknown, days will be FALSE."

In my case the code:

$d = new DateInterval('P1Y'); 
echo $d->days;

returns -99999

and a code like this

$a = DateTime::createFromFormat("d.m.Y", "01.01.2010");
$b = DateTime::createFromFormat("d.m.Y", "03.01.2010");

$d = $b->diff($a);
echo $d->days;

returns 6015

Did I misunderstand something?



DateInterval is buggy on windows platform. See bug #51183. The official answer seems to be "use VC9 builds instead for now".

Monday, August 15, 2022

This is the way to go. However, since what seems you want to do is to render the DateTime class extensible, I'd suggest you use static instead of self:

namespace NoiseLabsDateTime;

class DateTime extends DateTime
    static public function createFromFormat($format, $time)
        $ext_dt = new static();
        $parent_dt = parent::createFromFormat($format, $time);

        if (!$parent_dt) {
            return false;

        return $ext_dt;

It's not necessary if you don't plan on extending the class, but if someone ever does, it will prevent him from having to do the same workaround again.

Monday, November 7, 2022

Try to find the following line in your php.ini:

 display_errors = Off

then make it on

Sunday, September 25, 2022

EDIT 1: This may also have to do with the fact that getAllPersoonData and getAllLessenData have the same input signature, which means that, for document literal style web services, the endpoint won't be able to distinguish what kind of request you're actually making. Try passing two different element names.

EDIT 2: Also, giving these messages different signatures would allow you to put getPersoonID within the type definition so that you only have one message part. Right now, if you look in Customer.wsdl you have:

<wsdl:message name="getPersoonIDCustomerID">
    <wsdl:part name="body" element="ns:UserCredentials"/>
    <wsdl:part name="getPersoonID" type="xs:int"/>

You should not have more than one part in a document-literal message.

EDIT 3: If you don't want to define a new element for each function that you have, then you would have to switch to RPC literal, which wraps the request in the wsdl:operation name. If this would fix everything except .NET, then you could try my SO post on coaxing .NET into reading RPC-literal web services.

Saturday, August 13, 2022

The current version (1.9) of MAMP / MAMP PRO includes PHP 5.3 and is available on the MAMP download page.

Saturday, September 24, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :