I want to know how to override server time , my server is in UK but my Client is in Singapore and he wants Singapore time. in php.ini date.timezone is Europe/London which i do not want to change. i want to handle from config.php i tried this in codeigniter config.php
$config['time_diff']= "+8";
$config['time_reference'] = 'gmt';
date_default_timezone_set('UTC');
i also even tried this
$config['time_reference'] = 'local';
date_default_timezone_set('Singapore');
Within 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');
You have to use codeigniter date helper functions.
Go to application/config.php and set time_reference from local to your timezone.
$config['time_reference'] = 'Europe/London';
Now load date helper inside your controller
$this->load->helper('date');
echo now(); // it returns UNIX timestamp according to timezone set in config.
you can also pass timezone as parameter in now() function.
echo now('America/Los_Angeles');
References - system/helpers/date_helper.php https://www.codeigniter.com/user_guide/helpers/date_helper.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With