php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42755 date() returns incorrect time by +1 hour
Submitted: 2007-09-25 10:51 UTC Modified: 2007-12-09 12:08 UTC
Votes:9
Avg. Score:4.3 ± 0.9
Reproduced:8 of 8 (100.0%)
Same Version:7 (87.5%)
Same OS:4 (50.0%)
From: andrew at confirmalert dot com dot au Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.4 OS: Win 2003 Server SP2
Private report: No CVE-ID: None
 [2007-09-25 10:51 UTC] andrew at confirmalert dot com dot au
Description:
------------
Date function parses correct unix timestamp in PHP 5.0.3 but not in PHP 5.2.4.

I have set the timezone of the webserver to Casablanca Morroco which is a timezone that does not observe ANY daylight savings changes (i.e. it is a constant time) even though the server is physically located in San Diego USA.

Reproduce code:
---------------
date("Y-m-d @ g:i", 1190671200);

Expected result:
----------------
//Expected 2007-09-25 @ 8:00

Actual result:
--------------
//Produces 2007-09-25 @ 9:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-05 21:26 UTC] matthew at syxton dot com
I'm having the same issue with PHP 5.2.4 running on Linux platform.
 [2007-12-08 15:42 UTC] derick@php.net
What's the output of:

<?php
echo ini_get( 'date.timezone' ), "\n";
echo date_default_timezone_get(), "\n";

?>
 [2007-12-09 09:02 UTC] andrew at confirmalert dot com dot au
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.


C:\PHP>php test.php


Fatal error: Call to undefined function date_default_timezone_get() in C:\PHP\test.php on line 3

C:\PHP>php --version
PHP 5.0.3 (cli) (built: Dec 15 2004 08:07:57)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies

Timezone is '(GMT) Casablanca, Monrovia, Reykjavik'
 [2007-12-09 12:08 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

You wrote in your report that you were using PHP 5.2.4, but it's actually 5.0.3. Upgrade first.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 13:01:34 2025 UTC