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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 06:01:31 2024 UTC