logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



Setting the timezone in php?

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Mon 30 Oct '06 17:00    Post subject: Setting the timezone in php? Reply with quote

Hi,

I'm trying to get the date and time in php, for keeping logs, for security in my login pages etc.

I can get the date and time with no problems, but the timezone is all off and my server timezone is correct, i'm using Windows Server 2003 and php5 installed on IIS 6.

My time zone is actually GMT +02:00 but my php script shows EEST +0300
Why? and how do I correct this?

Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Mon 30 Oct '06 17:32    Post subject: Reply with quote

$tz="Europe/Berlin";
//set you locale timezone see http://www.php.net/manual/timezones.php


//only needed if you use PHP 5.1.x or greater
if(0 < version_compare(PHP_VERSION, '5.1.0')){
date_default_timezone_set($tz);
}
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1