2

Hey all - I am getting an error on my CMS site that reads as this:

Warning: strtotime(): 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 'UTC' for 'UTC/0.0/no DST' instead in /var/www/html/test-site/libs/utils.php on line 97.

So I went into that folder and placed this before any of the functions:

date.timezone = "America/New_York"; 

However, when i try to reload my page the entire site is down. Anyone know what I am doing wrong? Thanks

2
  • What you did was place a php.ini directive into your PHP code, and those directives are themselves not valid PHP code, so you introduced a syntax error. Commented Apr 20, 2011 at 19:19
  • Agree with @Marc + when you put this line into php.ini don't use ; at the and of line. Commented Apr 20, 2011 at 19:57

2 Answers 2

7

You can either choose to ignore the warning (which in most cases is fine), or explicitly set the time zone using date_default_timezone_set.

Writing date.timezone = "America/New_York"; isn't proper PHP, anyway.

Sign up to request clarification or add additional context in comments.

Comments

1

aha! I found that :

date_default_timezone_set('America/New_York'); 

Did the trick

3 Comments

No no no, this works but it's not the best method to do this, you should change the data.timezone within your php.ini file, and then restart apache or whatever server your using !
@Robert - I disagree. Even you set default.timezone in php.ini, PHP will try to 'guess' timezone before execution of every date/time function. Yes, it's good to set date.timezone in php.ini, but setting it again from php code is recommended. Even date_default_timezone_set(date_default_timezone_get()); makes sense. Look at this question and accepted answer. So I agree with @Sapp, this is the best way to avoid PHP 'guessing' timezone setting. @Sepp +1
sorry, i ment date.timezone in previous comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.