CodeIgniter Forums
How do you change the timezone? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How do you change the timezone? (/showthread.php?tid=62477)



How do you change the timezone? - rakibtg - 07-19-2015

Is there any Codeigniter way to change the entire website time zone?
Thanks for your time :=)


RE: How do you change the timezone? - Diederik - 07-19-2015

Have you tried with htaccess?
http://www.htaccess-guide.com/setting-server-timezone/


RE: How do you change the timezone? - CroNiX - 07-19-2015

Or use php's date_default_timezone_set() as the very first line of index.php. That will work using any webserver because it's at the php level, while htaccess only works with apache webservers.
http://php.net/manual/en/function.date-default-timezone-set.php


RE: How do you change the timezone? - wolfgang1983 - 07-19-2015

(07-19-2015, 09:46 AM)rakibtg Wrote: Is there any Codeigniter way to change the entire website time zone?
Thanks for your time :=)

I find that for changing the default time zone is best to add this


Code:
date_default_timezone_set('Australia/Queensland');

On to the config.php file Example I use Country/State


PHP Code:
<?php

defined
('BASEPATH') OR exit('No direct script access allowed');

date_default_timezone_set('Australia/Queensland');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will try guess the protocol, domain
| and path to your installation. However, you should always configure this
| explicitly and never rely on auto-guessing, especially in production
| environments.
|
*/
$config['base_url'] = ''



RE: How do you change the timezone? - skunkbad - 07-19-2015

Keep in mind that you may also need to change mysql's timezone if you are using MySQL.


RE: How do you change the timezone? - rakibtg - 07-19-2015

Thanks everyone, and special thanks goes to @skunkbad.
Once i changed the timezone then the entire website started to show inappropriate date, now after changing the mysql timezone its perfect now!