php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69089 Add support for RFC3339 extended to DateTime::format
Submitted: 2015-02-20 12:34 UTC Modified: 2015-03-09 21:50 UTC
From: mariano at cricava dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mariano at cricava dot com
New email:
PHP Version: OS:

 

 [2015-02-20 12:34 UTC] mariano at cricava dot com
Description:
------------
Currently there's no built in format for outputting DateTime using RFC 3339 extended, which is used in several APIs. An output using such format would look like:

2009-09-28T09:45:31.918-03:00

While PHP does have built in support for fraction of seconds in DateTime (provided the DateTime was constructed with it) through its %u format modifier, this modifier cannot be used for RFC 3339 extended as it is a 6 digit version of the fraction. Instead, a new format modifier is needed (proposed %v, because of its proximity with %u) to output the 3-digit version of the fraction. To see the difference, for the fraction 918312 here's what would be output by both modifiers:

%u: 918312
%v: 918

A new constant should be added to DateTime (such as RFC3339_EXTENDED) that would output strings in the RFC 3339 extended format, using this new %v modifier.

A pull request with relevant tests lives here:

https://github.com/php/php-src/pull/1103


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-04 20:00 UTC] ppaisndud at gmail dot com
Think the merge has already been done and can be closed
 [2015-03-04 20:00 UTC] ppaisndud at gmail dot com
Think the merge has already been done and can be closed
 [2015-03-04 20:08 UTC] mariano at cricava dot com
Yes, it was merged.

We would have this remaining (adding it to the changelog):

https://github.com/php/php-src/pull/1115
 [2015-03-09 21:49 UTC] mariano at cricava dot com
Last PR was merged as well, so this ticket is Fixed
 [2015-03-09 21:50 UTC] mariano at cricava dot com
-Status: Open +Status: Closed
 [2015-03-09 21:50 UTC] mariano at cricava dot com
Fixed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 05:01:29 2024 UTC