set default timezone when boot up

This commit is contained in:
printempw 2016-08-12 17:59:14 +08:00
parent 6dbcc7aacd
commit 46bf958215
3 changed files with 32 additions and 30 deletions

View File

@ -11,7 +11,32 @@ class Application
*/
public function run()
{
Boot::start();
// Load Aliases
Boot::loadServices();
// Check Runtime Environment
Boot::checkRuntimeEnv();
// Set Default Timezone to UTC+8
Boot::setTimeZone();
// Load dotenv Configuration
Boot::loadDotEnv(BASE_DIR);
// Register Error Handler
Boot::registerErrorHandler();
// Boot Eloquent ORM
Boot::bootEloquent(Config::getDbConfig());
// Redirect if not installed
Boot::checkInstallation();
// Start Session
Boot::startSession();
// Start Route Dispatching
Boot::bootRouter();
}
/**

View File

@ -9,33 +9,6 @@ use App\Exceptions\E;
class Boot
{
public static function start()
{
// Load Aliases
self::loadServices();
// Check Runtime Environment
self::checkRuntimeEnv();
// Load dotenv Configuration
self::loadDotEnv(BASE_DIR);
// Register Error Handler
self::registerErrorHandler();
// Boot Eloquent ORM
self::bootEloquent(Config::getDbConfig());
// Redirect if not installed
self::checkInstallation();
// Start Session
self::startSession();
// Start Route Dispatching
self::bootRouter();
}
public static function loadDotEnv($dir)
{
if (Config::checkDotEnvExist()) {
@ -44,6 +17,12 @@ class Boot
}
}
public static function setTimeZone($timezone = 'Asia/Shanghai')
{
// set default time zone, UTC+8 for default
date_default_timezone_set($timezone);
}
public static function checkRuntimeEnv()
{
Config::checkPHPVersion();

View File

@ -44,8 +44,6 @@ class Utils
public static function getTimeFormatted($timestamp = 0)
{
// set default time zone to UTC+8
date_default_timezone_set('Asia/Shanghai');
return ($timestamp == 0) ? date('Y-m-d H:i:s') : date('Y-m-d H:i:s', $timestamp);
}