Monthly Archives: January 2009

Adjust Server timezone ( time zone ) by adding helper file in CodeIgniter (code igniter, codeigniter, ci )

It has been seen that often the server is located in differnt timezones than ours….. Its been too tough to change the timezones in CodeIgniter for me. To resolve this problem we can add a simple helper file. For this you need to do the following steps.

Step 1. Create a folder in your applications folder named ‘helpers’

Step2. Save a file with named ‘zea_helper.php’ containing

function bd_time() {
 return mktime((gmdate('H').'GMT')+6, date("i"), date("s"), date("m"), date("d"), date("y"));
}

in the above created ‘helpers’ folder.  I have used +6 bceause bangladesh time is GMT 6+, if your time is GMT -4 you should write “(gmdate(‘H’) . GMT’)-4,” instead (gmdate(‘H’) . ‘ GMT’)+6,

Step3. Go to your autoload.php in config folder and change the line $autoload['helper'] = array(”); to $autoload['helper'] = array(‘zea’); and save the file.

Step4. Now just load the helper just like other helpers in your controller like $this->load->helper(‘zea’);. and start using it as a helpers

ex: echo date(“F j, Y, g:i a”,bd_time());

dont forget to load the helper in the controller.

Turn on / off for $register_globals by .htaccess file, “change from php4 to php5″

  1. Create a  file called .htaccess with any editor (like WordPad or Notes or dreamweaver or anyting).
  2. Add the following line in .htaccess:
    php_flag register_globals on
  3. Upload the file to your web hosting account(generally inside of public_html folder). Make sure the name of the file dosen’t have any kind of extension. The file name should be only .htaccess

Fell free to ask about it….