Re: DateInterval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is something i'd like to point out with DateInterval.

$dInt = 'PT4320S';
$d = new DateInterval($dInt);
var_dump($d);
$dz = new DateTimeZone(UTC);
$dt = new DateTime('now',$dz);
$dt->add($d);
var_dump($dt->format(DATE_ATOM));

It appears that running this code fails when it seems like it should work.

$dInt = 'PT43200S';
$d = new DateInterval($dInt);
var_dump($d);
$dz = new DateTimeZone(UTC);
$dt = new DateTime('now',$dz);
$dt->add($d);
var_dump($dt->format(DATE_ATOM));


Please note the first value in $dInt should be 72 minutes, while the later should be 720 minutes or half of a day

The PT12H  interval seems to work fine.

$dInt = 'PT12H';
$d = new DateInterval($dInt);
var_dump($d);
$dz = new DateTimeZone(UTC);
$dt = new DateTime('now',$dz);
$dt->add($d);
var_dump($dt->format(DATE_ATOM));


Raymond, have you tried using DateTime::modify? It appears to work like strtotime.
also DateTime::format works like date.  At least as far as I can tell.


Mike

Raymond Irving wrote:
Sounds great Mike.

I personally would also like to see standard date/time functions (strtotime, strftime, date, etc) support dates greater than 2038. I think this can be done internally by parsing the datetime value swith the DateInterval object and retuning the results to the standard functions.

Best regards,
__
Raymond Irving


--- On *Wed, 4/29/09, MIke Alaimo /<lists@xxxxxxxxxxxxxxxxxxx>/* wrote:


    From: MIke Alaimo <lists@xxxxxxxxxxxxxxxxxxx>
    Subject:  DateInterval
    To: php-general@xxxxxxxxxxxxx
    Date: Wednesday, April 29, 2009, 8:53 PM

    Hello,

I would like to know how to correctly use DateInterval::format(). The documentation is unclear.

    Also, I am willing to write some documentation for the
    DateInterval and DatePeriod if no one has taken the task.

    Thanks for the help.

    Mike

    -- PHP General Mailing List (http://www.php.net/)
    To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux