Из-за чего ошибка DateTime?

Добрый день всем!
Есть такой кусок
$month_now_first_day = new datetime('first day of 0 month midnight');
	$month_now_last_day = new datetime('last day of 0 month midnight');
	$month_now_first_day_in_time = strtotime($month_now_first_day->format('Y-m-d H:i:s'));
	$month_now_last_day_in_time = strtotime($month_now_last_day->format('Y-m-d H:i:s'));
	$month_now_text = strftime("%B", $month_now_first_day_in_time);

на одном сервере работает нормально, а на втором вываливается php с ошибкой
PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [datetime.--construct]: Failed to parse time string (first day of 0 month midnight) at position 10 (o): The timezone could not be found in the database' in /home/site/public_html/site/footer-index.php:64
Stack trace:
#0 /home/site/public_html/site/footer-index.php(64): DateTime->__construct('first day of 0 ...')
#1 /home/site/public_html/site/index.php(28): include('/home/site/...')
#2 {main}
thrown in /home/site/public_html/site/footer-index.php on line 64

date_default_timezone_set('Asia/Novosibirsk'); вставлен перед скриптом, плюс ко всему в htaccess строка SetEnv TZ UTC+06:00 без неё 500 ошибка у сервера о_О
Может кто помочь в чём проблема?
  • Вопрос задан
  • 6669 просмотров
Пригласить эксперта
Ответы на вопрос 2
Quber
@Quber
PHP Team lead
new datetime('first day of 0 month midnight');

Это что за формат такой? Правильнее будет скорее всего так:

new DateTime("2013-11-21 10:01:37");
new DateTime();
Ответ написан
miraage
@miraage
Старый прогер
Вы неправильно форматируете дату.

Попробуйте:
00:00 1st Jan
00:00 last day of Jan


Например,
date('Y-m-d H:i:s', strtotime('00:00 1st Jan'));
date('Y-m-d H:i:s', strtotime('00:00 last day of Jan'));
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы