Php ini date timezone

I'm trying to change the default PHP timezone to Asia/Calcutta by accessing the /etc/php5/cli/php.ini file and changing

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

to

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Calcutta"

However, when I try to view current timezone under phpinfo(), the timezone follows the Europe/Berlin timezone.

I have tried stopping and restarting the Apache server, but that didn't seem to have changed the settings.

Is there something I'm missing in the process?

PS: I'm using PHP 5.6.8 currently under XAMPP.

asked Aug 26, 2015 at 10:46

Manas ChaturvediManas Chaturvedi

4,82018 gold badges51 silver badges102 bronze badges

4

I tried all the other possible solutions posted, but none of them helped. This is what helped me save my timezone settings:

1) Go to your phpinfo() page and search for Loaded Configuration File and open the php.ini file mentioned under that section.

2) Change the default timezone settings by adding your new timezone by modifying this line: date.timezone=Asia/Kolkata.

3) Save the php.ini file and stop the Apache server.

4) Restart the Apache server. The timezone settings should now be modified.

answered Aug 26, 2015 at 12:43

Manas ChaturvediManas Chaturvedi

4,82018 gold badges51 silver badges102 bronze badges

3

You can change it in the code without touching the ini file, at the beginning of your code add:

date_default_timezone_set('Asia/Calcutta')

answered Aug 26, 2015 at 10:51

Php ini date timezone

Daniel KromDaniel Krom

9,4033 gold badges38 silver badges43 bronze badges

4

You are changing the wrong file. The file /etc/php5/cli/php.ini is used by cli - command line interface. Don't forget to restart your web-server after you update the right one: sudo service apache2 restart or sudo service php5-fpm restart

File locations for different OS:

OS                               ->  Location

windows(With Xampp Installation) -> /xampp/php/php.in 

Mac OSX                          -> /private/etc/php.ini

Linux                            -> /etc/php.ini

                                 -> /usr/bin/php5/bin/php.ini

                                 -> /etc/php/php.ini

                                 -> /etc/php5/apache2/php.ini

Php ini date timezone

Jocelyn

1,30611 silver badges20 bronze badges

answered Aug 26, 2015 at 10:53

4

I had the same problem and discovered that there are two date.timezone statements in php.ini in my version of XAMPP out of the box. The first statement one is commented out, but the second one is set to Europe/Berlin. So you if you edit your php.ini and search for timezone and logically uncomment the first statement with your time zone, the second statement overrides that back to Europe/Berlin.

answered Feb 5, 2019 at 0:17

0

  • phpinfo() was returning Loaded Configuration File => /etc/php/5.6/cli/php.ini.
  • My date.timezone changes were not taking effect after updating the above and restarting php-fpm (sudo systemctl reload php5.6-fpm.service).
  • phpinfo() also has an Additional .ini files parsed section, which contained /etc/php/5.6/cli/conf.d/timezone.ini.
  • After updating the timezone.ini file (date.timezone = "America/New_York") and restarting php-fpm (as above), phpinfo() correctly returned date.timezone => America/New_York => America/New_York.

answered Aug 24, 2021 at 19:35

Php ini date timezone

  1. If you 're serious about web developping get a VM going(Virtual Box + Vagrant).
  2. With XAMPP be careful. Sometimes there's more than 1 php.ini file and you might be editing the wrong one. To edit the real one, access it from the XAMPP control panel.
  3. You can use the a function in your code: date_default_timezone_set();

answered Aug 26, 2015 at 10:53

PatrickPatrick

1831 silver badge9 bronze badges

Check configuration in your system.

In my case, it was "Ubuntu"

sudo cat /etc/timezone Asia/Kolkata

Php ini date timezone

sandip

5138 silver badges23 bronze badges

answered Aug 18, 2018 at 7:40

Php ini date timezone

If you are using Laravel, you should change the Laravel timezone configuration.

My case Laravel 6. Edit /config/app.php file and change this line

'timezone' => 'UTC',

to

'timezone' => env('APP_TIMEZONE', 'UTC'),

then edit .env file. add your timezone (timezone list)

APP_TIMEZONE='America/New_York'

clear configurations

php artisan config:clear

answered Feb 21, 2021 at 15:33

Php ini date timezone

namalnamal

9401 gold badge9 silver badges14 bronze badges

Not the answer you're looking for? Browse other questions tagged php datetime or ask your own question.

Where is date timezone in PHP INI?

ini file is located at the /etc directory. Depending on the installed version of PHP version, you will find a [Date] section like the following. If it is not there, just add a line with the "date. timezone = Your/Timezone" function.

How do I change the default timezone in PHP INI?

8 Answers.
Go to your phpinfo() page and search for Loaded Configuration File and open the php. ini file mentioned under that section..
Change the default timezone settings by adding your new timezone by modifying this line: date. timezone=Asia/Kolkata ..
Save the php. ... .
Restart the Apache server..

What timezone is UTC for PHP?

The default timezone for PHP is UTC regardless of your server's timezone. This is the timezone used by all PHP date/time functions in your scripts. See PHP's list of supported timezones to find the names of all possible timezones you can use for the date.

What is timezone PHP?

date_default_timezone_get — Gets the default timezone used by all date/time functions in a script.