Hi!
I've been looking into various tests and discovered something strange in
date_diff. Example code:
<?php
$start = new DateTime('2010-10-04 02:18:48 EDT');
$end = new DateTime('2010-11-06 18:38:28 EDT');
$int = $start->diff($end);
var_dump($start);
As a result of this I'm getting this:
object(DateTime)#1 (3) {
["date"]=>
string(19) "2010-10-04 06:18:48"
["timezone_type"]=>
int(2)
["timezone"]=>
string(3) "EDT"
}
As you can see, the date in $start changed, even though it shouldn't
happen. Looks like it's because of timelib_diff() which has this:
timelib_apply_localtime(one, 0);
timelib_apply_localtime(two, 0);
which converts times in diff arguments to localtime. It then does:
timelib_apply_localtime(one, 1);
timelib_apply_localtime(two, 1);
which is supposed to convert them back, but in fact it does not, since
first conversion seems to have killed TZ information. I'd propose to fix
it by making time_diff operate on copies of one and two instead of real
structures, but maybe somebody has a better idea?
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php