php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64814 Nano precision is not supported while decoding RFC 3339 formatted date/times.
Submitted: 2013-05-10 17:29 UTC Modified: 2017-10-24 06:16 UTC
Votes:5
Avg. Score:4.6 ± 0.5
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: marc at weistroff dot net Assigned:
Status: Open Package: Date/time related
PHP Version: 5.5.0RC1 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-10 17:29 UTC] marc at weistroff dot net
Description:
------------
While trying to parse a RFC3339 datetime, PHP will generate the error "The 
timezone could not be found in the database".

It can cause problems with other systems that produce such date/time strings.

As you can see on http://3v4l.org/Bl1Kv, it affects php from version 5.2.0 to 
5.5.0.

Test script:
---------------
<?php
date_default_timezone_set('UTC');
var_dump(date_parse("2006-12-12T10:00:00.999999999-04:00"));
?>

Expected result:
----------------
array(15) {
  ["year"]=>
  int(2006)
  ["month"]=>
  int(12)
  ["day"]=>
  int(12)
  ["hour"]=>
  int(10)
  ["minute"]=>
  int(0)
  ["second"]=>
  int(0)
  ["fraction"]=>
  float(0.999999999)
  ["warning_count"]=>
  int(0)
  ["warnings"]=>
  array(0) {
  }
  ["error_count"]=>
  int(0)
  ["errors"]=>
  array(0) {
  }
  ["is_localtime"]=>
  bool(true)
  ["zone_type"]=>
  int(1)
  ["zone"]=>
  int(240)
  ["is_dst"]=>
  bool(false)
}

Actual result:
--------------
array(13) {
  ["year"]=>
  int(2006)
  ["month"]=>
  int(12)
  ["day"]=>
  int(12)
  ["hour"]=>
  int(10)
  ["minute"]=>
  int(0)
  ["second"]=>
  int(0)
  ["fraction"]=>
  float(0.99999999)
  ["warning_count"]=>
  int(0)
  ["warnings"]=>
  array(0) {
  }
  ["error_count"]=>
  int(1)
  ["errors"]=>
  array(1) {
    [0]=>
    string(47) "The timezone could not be found in the database"
  }
  ["is_localtime"]=>
  bool(true)
  ["zone_type"]=>
  int(0)
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-10 17:33 UTC] marc at weistroff dot net
I should have precise in the description of the bug that PHP returns an error when  
the number of digits in the "time-secfrac" part is > 8.
 [2015-02-11 07:43 UTC] friedrich dot grosse at gmail dot com
This is a problem for me when consuming JSON that has been generated by a service written in go. There the default format for time objects is RFC3339Nano
 [2017-04-21 15:52 UTC] antoine dot hedgecock at gmail dot com
I'm experience the same issue as the person above, go generate a timestamp with rfc3339 with a lot of precision. Php should just truncate the excess digits instead of failing with a very weird error.
 [2017-10-24 06:16 UTC] stas@php.net
-Type: Bug +Type: Feature/Change Request
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Aug 22 08:01:27 2019 UTC