php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32115 dateTime encoding of timezone incorrect
Submitted: 2005-02-25 22:22 UTC Modified: 2005-03-05 14:28 UTC
From: rtroll at yahoo-inc dot com Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5CVS-2005-02-25 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rtroll at yahoo-inc dot com
New email:
PHP Version: OS:

 

 [2005-02-25 22:22 UTC] rtroll at yahoo-inc dot com
Description:
------------
It looks like PHP's encoding of a dateTime value is incorrectly encoding the timezone.  For example, encoding unix time:

  1109366152

results in

  2005-02-25T13:15:52-0800

instead of:

  2005-02-25T13:15:52-08:00

The timezone offset must contain a colon, according to

  http://www.w3.org/TR/xmlschema-2/

Section 3.2.7.3: Timezones


Reproduce code:
---------------
<?php
$WSDL = "http://ws1.api.re2.yahoo.com/ws/soap-demo/full.wsdl";
$client = new SoapClient( $WSDL, array( "trace" => true,
                                        "exceptions" => 0,
                                        ));
function dump_xml( $title, $body )
{
    $nl = preg_replace( "/\>\</", ">\n<", $body );
    $clean = htmlspecialchars( $nl );
    print "\n<b>$title</b>\n<pre>$clean</pre>\n";
}
$t = time();
$r = $client->dateInfo( array( 'dtval' => $t ) );
$dateTime_pst = strftime( "%Y-%m-%dT%H:%M:%S-08:00", time() ); # Works 'cause server is in PST zone
$dateTime_utc = gmstrftime( "%Y-%m-%dT%H:%M:%SZ", time() );
echo "<h2>Bug</h2>Request should have converted unix timestamp [$t] to xs:dateTime string [$dateTime_utc] or [$dateTime_pst].  Instead, request is:<br>\n";

dump_xml( "Request", $client->__getLastRequest() );


Expected result:
----------------
Request should be similiar to:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:yahoo:platform:soap:demo:full">
<SOAP-ENV:Body>
<ns1:dateInfo>
<ns1:dtval>2005-02-25T13:19:10-08:00</ns1:dtval>
</ns1:dateInfo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Actual result:
--------------
Request is currently:


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:yahoo:platform:soap:demo:full">
<SOAP-ENV:Body>
<ns1:dateInfo>
<ns1:dtval>2005-02-25T13:19:10-0800</ns1:dtval>
</ns1:dateInfo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-05 14:28 UTC] dmitry@php.net
Fixed in CVS (HEAD and PHP_5_0).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 30 00:01:28 2024 UTC