set default timezone for date/time functions

by Ramya 2009-08-06 18:00:05

How to change the default timezone in PHP:

-- I have come across an issue that,
"I have converted GMT timestamp to UNIX timestamp using PHP mktime() and i got correct result in my localhost but when i uploaded that file into site, i got a different answer in my server.
For eg,
$tim = mktime(0,0,0,7,13,2009);
Result in local,
1247443200.
Result in server,
1247423400.

Searched for a while and finally found that the issue was in the timezone used in localhost and site. This is because server may use common timezone."

-- Inorder to set default timezone to the required timezone use, "date_default_timezone_set()".
For eg,
date_default_timezone_set(UTC);
$tim = mktime(0,0,0,7,13,2009);
Result in local,

-- Likewise, to get the default timezone use,"date_default_timezone_get()"
It will result the type of timezone which you have set to your system.

There are lot of timezones available in PHP.

Tagged in:

1929
like
0
dislike
0
mail
flag

You must LOGIN to add comments