Re: DateInterval
| From: | MIke Alaimo | Date: | Thu, 30 Apr 2009 03:04:28 +0000 |
| Subject: | Re: DateInterval | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-292141@lists.php.net to get a copy of this message | ||
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@reptiliannature.org>/* wrote:From: MIke Alaimo <lists@reptiliannature.org> Subject: [PHP] DateInterval To: php-general@lists.php.net Date: Wednesday, April 29, 2009, 8:53 PMHello,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