Where should I set the default timezone? |
[eluser]shuki[/eluser]
Hello, I am writing an application that will be used in one timezone (Israel) and I wonder where should I set the timezone so that it will affect all the date/time functions? Code: date_default_timezone_set('Israel'); Thanks, Shuki
[eluser]Prasad.P[/eluser]
You can place that statement in model, if you use or definitely in controller
[eluser]Michael Wales[/eluser]
I would place it in index.php - right below the error_reporting line (or is that config.php... can't remember - config.php would be a better place, logically).
[eluser]shuki[/eluser]
Thanks for your answers Prasad.P and Michael Wales. I suppose that I can create a new library that I will auto load which will execute the Code: date_default_timezone_set('Israel'); I will place the value 'Israel' in a config file for that library to keep a separation between parameters and execution. This library could then be extended to cater for other application settings.
[eluser]aroman[/eluser]
is there any workaround function for date_default_timezone_set( ) tht will works in php4? -thanks
[eluser]Crafter[/eluser]
I would avoid interfering with the index file and this may lead to "forgot-to-do-that: syndrome when upgrading, An autoload library might be more appropriate. One of the config files might be even better.
[eluser]zea726[/eluser]
Hey where to add this date_default_timezone_set('Israel'); I tried to add this in a function of a controller. But as soon as i added this everything went to blank plz help me....
[eluser]aroman[/eluser]
[quote author="zea726" date="1231590216"]Hey where to add this date_default_timezone_set('Israel'); I tried to add this in a function of a controller. But as soon as i added this everything went to blank plz help me....[/quote] You can put that function inside the index.php located in the root of your CI, just below the error_reporting(E_ALL) This function will works in PHP5 only. : )
[eluser]zea726[/eluser]
Hey... Thanks for ur answer... Somehow its not working... So I have added a helper file for adjusting the timezone and using it as heleper Code: <?php if u plz tell me is this right way or not?? Thanks once again.
[eluser]Andreas Bergström[/eluser]
I have problems with website going blank when adding date_default_timezone_set('Sweden'); to index.php. I'm on CI 2.1 and NGINX, PHP5, APC. Never experienced this on Apache. Edit: Found answer here: http://stackoverflow.com/questions/48827...ith-php5-3 |
Welcome Guest, Not a member yet? Register Sign In |