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.

Comments (7)

KrisBelucciJune 2nd, 2009 at 10:28 am

Great post! Just wanted to let you know you have a new subscriber- me!

Kelly BrownJune 13th, 2009 at 1:06 am

Hi, interest post. I’ll write you later about few questions!

GarykPattonJune 16th, 2009 at 6:21 pm

Hi. I like the way you write. Will you post some more articles?

Roulette StrategieSeptember 10th, 2009 at 5:38 am

I cannot believe this will work!

competitive intelligenceDecember 1st, 2009 at 11:03 pm

great post

competitive intelligence

PaydayloanJanuary 25th, 2010 at 4:29 am

Good Luck

seo companyJanuary 28th, 2010 at 9:07 pm

I should harmonise with your point. You stated it down so well. I just bookmarked your post. thanks

Leave a comment

Your comment