Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP date_default_timezone_set()

Tags:

timezone

php

In php, is there a way to set default timezone in .htaccess or wherever, as long as i don have to set it at every php page.

provided i don have access to server, only PHP files. Thanks in advance

UPDATE

i am using apache (LAMP), and don't have access to php.ini

like image 598
Loonb Avatar asked Dec 17 '12 14:12

Loonb


People also ask

What is the use of Date_default_timezone_set ()?

The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script.

What is the default time zone?

US' Default Time Zone Unfortunately, there is no default time, so you have to change your time depending on the time zone used in the place.


1 Answers

Considering you use apache from the fact you mention .htaccess:

Yes, as long as it runs mod_php it is possible in .htaccess like so:

php_value date.timezone "Europe/Berlin"

Or you could set date.timezone in php.ini like Karl Laurentius Roos suggested. This would only be possible if you have access to your php config through. Remember to restart PHP (CGI mode) or your webserver (mod_php) after altering php.ini.

like image 83
Hikaru-Shindo Avatar answered Oct 02 '22 18:10

Hikaru-Shindo