Bug #71386 [Opn->Nab]: Date returns the wrong month

From: Date: Sat, 16 Jan 2016 04:54:23 +0000
Subject: Bug #71386 [Opn->Nab]: Date returns the wrong month
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198707@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71386&edit=1

 ID:                 71386
 Updated by:         requinix@php.net
 Reported by:        ualison dot aguiar at gmail dot com
 Summary:             Date returns the wrong month
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux - Open Suse
 PHP Version:        5.6.17
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/manual/en/datetime.formats.date.php

#/#/# is interpreted to be either m/d/y or y/m/d. Use a different format for your string.


Previous Comments:
------------------------------------------------------------------------
[2016-01-16 00:51:27] ualison dot aguiar at gmail dot com

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


Thread (2 messages)

« previous php.bugs (#198707) next »