1

如何根据时区在codeigniter中回显时间?

4

1 回答 1

3

首先,在配置文件中将主时间参考设置为“GMT”:

$config['time_reference'] = 'gmt';

从http://codeigniter.com/user_guide/helpers/date_helper.html中的时区参考中选择,或使用 timezone_menu() 在下面的代码中为 $timezone 设置变量或更新数据库列:

$time = now();  
$timezone = 'UM5';  
$daylight_saving = TRUE; // or FALSE  
$local_time = unix_to_human(gmt_to_local($time, $timezone, $daylight_saving));  
echo $local_time;
于 2011-04-05T11:22:06.010 回答