我想知道如何覆盖服务器时间,我的服务器在英国,但我的客户在新加坡,他想要新加坡时间。在php.ini,date.timezone是欧洲/伦敦,我不想改变它。我想从config.php中处理,我在代码点火器config.php中尝试过这个
$config['time_diff']= "+8";
$config['time_reference'] = 'gmt';
date_default_timezone_set('UTC');
我也试过这个
$config['time_reference'] = 'local';
date_default_timezone_set('Singapore');
发布于 2015-05-27 08:48:30
在config.php内
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
date_default_timezone_set('Asia/Singapore');
发布于 2017-04-27 06:26:58
您必须使用代码点火器日期助手函数。
转到application/config.php并将time_reference从本地设置为您的时区。
$config['time_reference'] = 'Europe/London';
现在,在控制器中加载日期助手。
$this->load->helper('date');
echo now(); // it returns UNIX timestamp according to timezone set in config.
还可以在now()函数中将时区作为参数传递。
echo now('America/Los_Angeles');
参考资料- system/helpers/date_helper.php helper.html
https://stackoverflow.com/questions/30476902
复制相似问题