Bug #71386 [NEW]: Date returns the wrong month
From: ualison dot aguiar at gmail dot com
Operating system: Linux - Open Suse
PHP version: 5.6.17
Package: Date/time related
Bug Type: Bug
Bug description: Date returns the wrong month
Description:
------------
When you run the script method format returns different date than was
reported in the __construct
Test script:
---------------
1º Case
<?php
date_default_timezone_set('America/Sao_Paulo');
$date = new \DateTime('01/02/2016');
var_dump($date->format('d/m/Y'));
?>
2º Case
<?php
date_default_timezone_set('America/Sao_Paulo');
$date = new \DateTime('01/02/2016');
var_dump($date);
?>
Expected result:
----------------
1º Case
string(10) "01/02/2016"
2º Case
class DateTime#1 (3) {
public $date =>
string(26) "2016-02-01 00:00:00.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(17) "America/Sao_Paulo"
}
Actual result:
--------------
1º Case
02/01/2016
2º Case
Displays the following result
class DateTime#1 (3) {
public $date =>
string(26) "2016-01-02 00:00:00.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(17) "America/Sao_Paulo"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=71386&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71386&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71386&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71386&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71386&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71386&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71386&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71386&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71386&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71386&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71386&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71386&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71386&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71386&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71386&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71386&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71386&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71386&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71386&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71386&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71386&r=mysqlcfg
Thread (2 messages)
- ualison dot aguiar at gmail dot com