Bug #69205 [NEW]: DateTime for December 31st fails once every 400 years

From: Date: Mon, 09 Mar 2015 15:23:41 +0000
Subject: Bug #69205 [NEW]: DateTime for December 31st fails once every 400 years
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191267@lists.php.net to get a copy of this message
From:             nd dot wortel at gmail dot com
Operating system: Ubuntu 14.04
PHP version:      5.5.22
Package:          Date/time related
Bug Type:         Bug
Bug description:DateTime for December 31st fails once every 400 years

Description:
------------
A DateTime (or DateTimeImmutable) object can not be created with date
'2369-12-31', '2769-12-31', '3169-12-31', etc. Instead, a DateTime
object with date '2370-01-00' (or '2770-01-00', '3170-01-00', etc.) is
created. This happens every 400 years on December 31st.

Years in the past are not affected: '1969-12-31' and '1569-12-31' work
just fine. Therefore, this has probably something to do with the Unix
time system.

Note: my PHP version is actually PHP 5.5.9-1ubuntu4.6.

This bug is probably also causing the behavior described here:
https://bugs.php.net/bug.php?id=67993

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

$dateTime = new DateTime('2369-12-31'); // or 2769, 3169, etc.

var_dump($dateTime);

Expected result:
----------------
object(DateTime)[1]
  public 'date' => string '2369-12-31 00:00:00' (length=19)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Amsterdam' (length=16)

Actual result:
--------------
object(DateTime)[1]
  public 'date' => string '2370-01-00 00:00:00' (length=19)
  public 'timezone_type' => int 3
  public 'timezone' => string 'Europe/Amsterdam' (length=16)

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



Thread (11 messages)

« previous php.bugs (#191267) next »