php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72478 Wrong Unix Timestamps
Submitted: 2016-06-23 10:50 UTC Modified: 2016-06-23 15:22 UTC
From: deivid dot garcia dot garcia at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Date/time related
PHP Version: 7.0.7 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: deivid dot garcia dot garcia at gmail dot com
New email:
PHP Version: OS:

 

 [2016-06-23 10:50 UTC] deivid dot garcia dot garcia at gmail dot com
Description:
------------
The DateTime::createFromFormat method seems to ignore the DateTimeZone parameter.

On the sample script, $t should be 

Test script:
---------------
$time = "2016-05-25 09:30:00";
// This is the expected timestamp considering $time is in UTC.
$timestamp = 1464168600;
$format = "Y-m-d H:i:s";
$date = \DateTime::createFromFormat($format, $time, new \DateTimeZone('America/Tegucigalpa'));
$t = $date->format('U'); //1464190200

if ($t !== $timestamp) {
  throw new \Exception('¿??¿?¿');
}

Expected result:
----------------
No exception thrown.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-23 15:22 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-06-23 15:22 UTC] cmb@php.net
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

See <https://3v4l.org/tohfa>; you're comparing an int with a
string with !==.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 14:01:27 2025 UTC