Req #70701 [NEW]: Add support for seconds in timezone offset

From: Date: Mon, 12 Oct 2015 22:23:41 +0000
Subject: Req #70701 [NEW]: Add support for seconds in timezone offset
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196576@lists.php.net to get a copy of this message
From:             p at wspnr dot com
Operating system: All
PHP version:      7.0.0RC4
Package:          Date/time related
Bug Type:         Feature/Change Request
Bug description:Add support for seconds in timezone offset

Description:
------------
The \DateTime and \DateTimeImmutable classes correctly handle timezone
offsets of the format "-05" (hours) and "-05:30" (hours and minutes),
but NOT "-05:30:30" (hours, minutes and seconds).

Given that the "Z" format code is available, presumably timezone offsets
at this level of precision are supported.

The use case for this is interoperability with other applications. For
instance, a timestamptz field in PostgreSQL 9.4 can have timezone
offsets of this format.





Test script:
---------------
<?php

$dt1 = new \DateTime("2015-09-15 01:15-05:30");
echo $dt1->format("Y-m-d\TH:i:s.uZ");

$dt2 = new \DateTime("2015-09-15 01:15-05:30:30");
echo $dt2->format("Y-m-d\TH:i:s.uZ");

Expected result:
----------------
2015-09-15T01:15:00.000000-19800
2015-09-15T01:15:00.000000-19830

Actual result:
--------------
2015-09-15T01:15:00.000000-19800
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to
parse time string (2015-09-15 01:15-05:30:30) at position 22 (:):
Unexpected character in /.../file.php

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70701&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70701&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70701&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70701&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70701&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70701&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70701&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70701&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70701&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70701&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70701&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70701&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70701&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70701&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70701&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70701&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70701&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70701&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70701&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70701&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70701&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#196576) next »