Jump to content

Recommended Posts

Posted

Hello,

I am wondering if any admin would change my default TimeZone to "Asia/Dhaka".

Regards,

Meraj

Posted

You have to do this in your scripts. I think it can be changed with set_ini...can't test though since I'm on my phone at the moment.

 

We can't change it in the ini because it there is only one php.ini that affects everyone on the server (There isn't an ini for each user).

Posted

I used following code on htaccess file:

SetEnv TZ Asia/Dhaka

It seems worked when I view phpinfo();

But in scripts automatically using server time (maybe UTC). Any idea to set default tz for scripts?

TIA

Posted

TZ works for older versions of PHP, in newer versions date.timezone.

In my PHP scripts I have:

putenv("TZ=UTC"); // enough for older PHP versions
date_default_timezone_set('UTC'); // required for newer PHP versions

I set it inside of my scripts as I use two or more timezones at once (for displaying two time graphs).

 

In .htaccess, If I'm right, it will looks like:

php_value date.timezone "UTC"
Posted

 

date_default_timezone_set('UTC'); // required for newer PHP versions

 

This is the correct way to do it. I usually put stuff like this in a file called config.php and require_once it at the top of all of the php scripts in that project. That way you just have to change it in one place rather than having to change it in 15 different places.
Posted

I already using a config file which incudes settings, header, footer, etc info for each page. Because it's too time spending to add infos in every page. I used to include config file, then call any info by functions. Thanks anyway for helping me. I will use your code to my config file. :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...