php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44106 date_create with '@'timestamp ignores timezone
Submitted: 2008-02-12 21:35 UTC Modified: 2008-02-12 22:28 UTC
From: phpbugs at rootcrew dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3CVS-2008-02-12 (snap) OS: Linux (Ubuntu/Debian)
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: phpbugs at rootcrew dot net
New email:
PHP Version: OS:

 

 [2008-02-12 21:35 UTC] phpbugs at rootcrew dot net
Description:
------------
using "date_create('@'.$timestamp)" ignores the default timezone setting, giving the timezone as second parameter does not work either.

tested with 5.2.3-1ubuntu6.3, 5.2.0-8+etch10
and tested with snapshot: 5.3-200802121930

Reproduce code:
---------------
$t= time();
$tz= date_default_timezone_get();
$d1= date_create(date("c", $t));
$d2= date_create("@$t"); // ignores default timezone
$d3= date_create("@$t", new DateTimeZone($tz)); // ignores timezone too

echo "default timezone: $tz\n";
echo $d1->format(DATE_RFC2822)."\n";
echo $d2->format(DATE_RFC2822)."\n";
echo $d3->format(DATE_RFC2822)."\n";


Expected result:
----------------
default timezone: Europe/Berlin
Tue, 12 Feb 2008 22:11:23 +0100
Tue, 12 Feb 2008 22:11:23 +0100
Tue, 12 Feb 2008 22:11:23 +0100


Actual result:
--------------
default timezone: Europe/Berlin
Tue, 12 Feb 2008 22:11:23 +0100
Tue, 12 Feb 2008 21:11:23 +0000
Tue, 12 Feb 2008 21:11:23 +0000


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-12 22:28 UTC] derick@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

Using @ with a time stamp, implicitly uses UTC as timezone. The default timezone or the timezone passed as 2nd argument will only be used if no TZ is associated with the string. As @ already makes UTC associated with it, they are ignored.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 02 11:00:03 2025 UTC