mrj Posted October 1, 2017 Posted October 1, 2017 Hello,I am wondering if any admin would change my default TimeZone to "Asia/Dhaka".Regards,Meraj Quote
wolstech Posted October 1, 2017 Posted October 1, 2017 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). Quote
mrj Posted October 1, 2017 Author Posted October 1, 2017 I used following code on htaccess file:SetEnv TZ Asia/DhakaIt seems worked when I view phpinfo();But in scripts automatically using server time (maybe UTC). Any idea to set default tz for scripts?TIA Quote
Piotr GRD Posted October 1, 2017 Posted October 1, 2017 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 versionsI 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" Quote
Krydos Posted October 2, 2017 Posted October 2, 2017 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. Quote
mrj Posted October 2, 2017 Author Posted October 2, 2017 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.