D
D
dimas092014-10-28 20:22:08
PHP
dimas09, 2014-10-28 20:22:08

Why is PHP returning a date that doesn't match the system date?

After the time change in Russia, on the server where the Europe/Moscow timezones were everywhere, the time did not change. But after installing tzdate, the system time was fixed, I write in the console date gives the correct time. I write in php -r "echo date('Ymd H:i:s');" I get an hour more.
Reinstalling php does not help.
What do you advise to do.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
My joy, 2014-10-28
@t-alexashka

another php.ini works through the console (/etc/php5/cli/) there set the default zone Europe/Moscow

A
akarin, 2014-10-28
@akarin

php.net/manual/ru/datetime.configuration.php

N
neolink, 2014-10-28
@neolink

PHP version, what system?
which outputs:

<?php

echo "Default TZ: ", date_default_timezone_get();

$r = new \ReflectionExtension('date');
echo $r->info();

I
Ilya, 2014-11-10
@glebovgin

Just struggled with this problem myself (Debian 6, php 5.3.29). Here is my solution (as root):

apt-get install php-pear php5-dev build-essential
pecl install timezonedb
echo "extension=timezonedb.so" > /etc/php5/conf.d/timezonedb.ini

After that, you need to restart Apache
I really hope that it helps.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question