• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where should I set the default timezone?

#1
[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

#2
[eluser]Prasad.P[/eluser]
You can place that statement in model, if you use or definitely in controller

#3
[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).

#4
[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');
line.

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.

#5
[eluser]aroman[/eluser]
is there any workaround function for date_default_timezone_set( ) tht will works in php4?
-thanks

#6
[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.

#7
[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....

#8
[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.

: )

#9
[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
    function bd_time() {
        return mktime((gmdate('H') . ' GMT')+6, date("i"), date("s"), date("m"), date("d"), date("y"));
    }
?>

if u plz tell me is this right way or not??

Thanks once again.

#10
[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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.