Skip to content

DateTime modify function not respect Time Zone #14661

Open
@piotrek-lifeinmobile

Description

@piotrek-lifeinmobile

Description

The following code:

<?php
var_dump((new DateTime())->modify("2024-06-21T13:03:20-04:00"));

Resulted in this output(php >=8.2.5; >=8.3.0):

object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2024-06-21 13:03:20.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(3) "UTC"
}

But I expected this output instead(this works on php 8.2.4, 8.2.3, 8.2.2):

object(DateTime)#1 (3) {
  ["date"]=>
  string(26) "2024-06-21 13:03:20.000000"
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "-04:00"
}

PHP Version

=8.2.5; >=8.3.0;

Operating System

Any Linux or Windows

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions