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

From: Date: Mon, 12 Oct 2015 22:26:31 +0000
Subject: Req #70701 [Opn]: Add support for seconds in timezone offset
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196577@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70701&edit=1

 ID:                 70701
 Updated by:         rasmus@php.net
 Reported by:        p at wspnr dot com
 Summary:            Add support for seconds in timezone offset
 Status:             Open
 Type:               Feature/Change Request
 Package:            Date/time related
 Operating System:   All
 PHP Version:        7.0.0RC4
 Block user comment: N
 Private report:     N

 New Comment:

But we don't have any timezones on this planet that has an offset that needs second
granularity, do we? I wonder what the use case for this is in PostgreSQL?


Previous Comments:
------------------------------------------------------------------------
[2015-10-12 22:23:39] p at wspnr dot com

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 this bug report at https://bugs.php.net/bug.php?id=70701&edit=1


Thread (7 messages)

« previous php.bugs (#196577) next »