Bug #54253 [Bgs]: Date H (and h) returns +7 hours
| From: | rasmus@php.net | Date: | Mon, 14 Mar 2011 23:31:40 +0000 |
| Subject: | Bug #54253 [Bgs]: Date H (and h) returns +7 hours | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159480@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54253&edit=1
ID: 54253
Updated by: rasmus@php.net
Reported by: sunco007 at hotmail dot com
Summary: Date H (and h) returns +7 hours
Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Windows 7 x32
PHP Version: 5.3.5
Block user comment: N
Private report: N
New Comment:
It does try to detect it. Many servers run in UTC by default, so yes,
you should
set your timezone in your php.ini or if you don't have access to that in
some
common include file.
Previous Comments:
------------------------------------------------------------------------
[2011-03-15 00:28:32] sunco007 at hotmail dot com
Ok. Your answer is the correct but..
Do i need to add that line to ALL my php files ? (lets say i have 100)
Ok.. i can change one line on php.ini but.. What about if I use a
hosting provider and they don't want to change it ?
I think is much better if Php reads the timezone directly from the PC,
just as Mysql does
What do you think about that ?
------------------------------------------------------------------------
[2011-03-15 00:03:06] rasmus@php.net
Or I guess you are Pacific actually. Then use:
date_default_timezone_set('America/Los_Angeles');
------------------------------------------------------------------------
[2011-03-15 00:02:00] rasmus@php.net
Set your timezone. You are getting UTC back.
date_default_timezone_set('America/Denver');
------------------------------------------------------------------------
[2011-03-14 23:58:07] sunco007 at hotmail dot com
Description:
------------
Want to get the date without any calculations and i got it wrong
Is 15:54:09 and Php..
date("H:i:s") returns me 22:54:09
date("h:i:s") returns me 10:54:09
Maybe you need to check exactly on March 14 2011 to see the same result
as me
Test script:
---------------
<?
echo date("H:i:s");
// or
echo date("h:i:s");
?>
Expected result:
----------------
Current time
Actual result:
--------------
The time +7 hours
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54253&edit=1