php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64294 date conversion problem when dst present
Submitted: 2013-02-25 09:55 UTC Modified: 2013-11-27 17:26 UTC
From: ybrigant at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.22 OS: linux 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: ybrigant at gmail dot com
New email:
PHP Version: OS:

 

 [2013-02-25 09:55 UTC] ybrigant at gmail dot com
Description:
------------
COnversion of an utc timestamp to a date in a scpecific timezone, ie EUrope/Paris where we have dst activated in the date example...

Test script:
---------------
$timestamp = 1382954400;
$date = new \DateTime('@'.$timestamp);
$tz = new \DateTimeZone('Europe/Paris');
$date->setTimezone($tz);
return $date->format(Y-m-d H:i');

Expected result:
----------------
2013-10-28 12:00

Actual result:
--------------
2013-10-28 11:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-25 10:42 UTC] ybrigant at gmail dot com
Sorry, I forgot to add that timestamp provided is in utc timezone.
 [2013-02-27 01:26 UTC] mail+php at requinix dot net
DST in Europe ends at 2013-10-27 01:00.

By the way, Unix timestamps don't have timezones.
 [2013-02-27 01:28 UTC] mail+php at requinix dot net
01:00 UTC that is, so 02:00 Europe/Paris.
 [2013-11-27 17:26 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2013-11-27 17:26 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

This does look just fine:

<?php
$timestamp = 1382954400;
$date = new \DateTime('@'.$timestamp);
echo $date->format('Y-m-d H:i T O'), "\n";
$tz = new \DateTimeZone('Europe/Paris');
$date->setTimezone($tz);
echo $date->format('Y-m-d H:i T O'), "\n";
?>

outputs as expected:

2013-10-28 10:00 GMT+0000 +0000
2013-10-28 11:00 CET +0100
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jan 11 18:01:28 2025 UTC