Все настройки Yii — по умолчанию.
Есть класс Timestamp, расположенный в protected\utils\Timestamp.php
Код: Выделить всё
<?php
namespace application\utils;
class Timestamp
{
/**
* @return integer get local time zone offset with dst from UTC
*/
public static function getUTCDiff()
{
static $OFFSET;
if (isset($OFFSET)) return $OFFSET;
$tz = new DateTimeZone(Yii::app()->timeZone);
// получаем текущий офсет времени в секундах от UTC/GMT+0 (здесь летнее время уже учтено)
$OFFSET = $tz->getOffset(new DateTime('now', new DateTimeZone('UTC')));
return $OFFSET;
}
}
?>
Код: Выделить всё
<?php
use application\utils\Timestamp as T;
...
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
Yii::app()->timeZone = 'America/New_york';
date_default_timezone_set(Yii::app()->timeZone);
$tzOffset = T::getUTCDiff()/3600;
$this->render('index');
}
?>
include(Z:\home\SITENAME\www\protected\utils\DateTimeZone.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory.
Первый раз пробую работать с namespace, поэтому не уверен, что это ошибка. Но если все-таки это ошибка, то причина, по-моему, в том, что в методе YiiBase::autoload($className) нет проверки на существование класса $className "самого по себе" (вне импортированного namespace).