• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timezone help

It can be done for default time zone..

// time() will return new york time, i will use this to store every time and date in db  
$time = now();
$timezone = 'UP1'; // serbia timezone utc + 1
$local_time = unix_to_human(gmt_to_local($time, $timezone));  
echo $local_time;

This way, it works.. there wont be a problem to use like this ?

[quote author="InsiteFX" date="1328579156"]First off you need to set the correct time of where your server is!
I add this to the top of index.php for my servers time!
*  set the default timezone.

Excuse me, i don not understand why we need to set manually the default timezone before using the date helper: if we call directly PHP date/time functions they will use the server time, if we call the CodeIgniter Date/Time functions they will use the timezone set in the config file, where is the problem?


Then maybe you should read the post better!

[quote author="InsiteFX" date="1329167163"]Then maybe you should read the post better![/quote]

I was focusing on your telling that if you do not set manually the default timezone of the server then sessions and cookies will not work properly and I do not understand why. Probably my limit, that's why I was asking.

What I understand of the time management in CI is that if you do use PHP native sessions and cookie or date/time functions then the default timezone set by the server itself will be used, while if you use CI session and cookie or date/time helper the config setting of CI should be used instead.

If your server is in America/New York, that will be already the default timezone set, why should you confirm it again manually? It creates also a portability issue: if you do change hosting and go to California you have to remember and change manually again the default timezone, isn't it?


EDIT on March 2012: The answer to my question is in the new version of PHP 5.4. When running phpinfo() without setting the timezone, the following warning appears:

Quote:Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /your/path/to/phpinfo.php on line 3

So, PHP push to standardize the date/time management avoiding each server will set its own according to the local time.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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