Reputation: 6085
how to echo out time in codeigniter based on timezone ?
Upvotes: 1
Views: 3038
Reputation: 770
First, set your master time reference to 'GMT' in your config file:
$config['time_reference'] = 'gmt';
Choose from timezone reference in http://codeigniter.com/user_guide/helpers/date_helper.html or use the timezone_menu() to set a variable or update a DB column for $timezone in the code below:
$time = now();
$timezone = 'UM5';
$daylight_saving = TRUE; // or FALSE
$local_time = unix_to_human(gmt_to_local($time, $timezone, $daylight_saving));
echo $local_time;
Upvotes: 3