PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » SOAP » Bug #4523

SOAP datetimes interpreted incorrectly when timezone absent

Details

Submitted2005-06-03 23:58 UTC
Fromcmaddocks at maddocks dot ca
Assignedyunosh
StatusClosed
PackageSOAP
PHP Version4.2.2
OSWindows 2000 SP4
Roadmaps(Not assigned)

Comments

[2005-06-03 23:58 UTC] cmaddocks at maddocks dot ca

Description:
------------
The constructor of the SOAP_Type_dateTime class can take an iso-8601 date as a parameter. In the absence of a UTC offset and the 'Z' character (which signifies UTC time) the time is to be interpreted as in some local timezone.

However, the way the class processes the timestamp (SOAP_Type_dateTime::toUnixTime -> SOAP_Type_dateTime::_split, strtotime) effectively interprets all timestamps lacking timezone information as UTC times, not local times.

toUnixtime always returns a UTC-measured timestamp (it tacks a "Z" on the end of its output). Therefore, _split needs to apply the offset of the *local* timezone if none was specified in the timestamp.

Reproduce code:
---------------
Unit testing the SOAP/Type/dateTime.php :

$ts = new SOAP_Type_dateTime( '2001-04-25T09:31:41');
print $ts->toString();

Here's a diff on dateTime.php (based on PEAR::SOAP 0.9.1 beta):

68c68,69
< if ($regs[8] != '' && $regs[8] != 'Z') {
---
> if ($regs[8] == '') $regs[8] = date( "O" );
> if ($regs[8] != 'Z') {

Expected result:
----------------
2001-04-25T09:31:41-0400
(Web server is in UTC-0400)

Actual result:
--------------
2001-04-25T05:31:41-0400