WebFaction
Community site: login faq

I am getting the following warning...

Warning: strtotime() [function.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 'America/Chicago' for 'CDT/-5.0/DST'

On a page that generates an image Content-Type. I think this may explain why the generation sometimes fails (I added some scripting to recover from failing a while back) but the problem has been around for a long time, so maybe not. Either way it does not strike me as random noise.

I think I have a cgi file running PHP at the moment. Any advice?

Obviously I don't want to be in the position of hardcoding the server's timezone even if I knew what that was :)

Thanks.

asked 31 Aug '12, 05:22

Mick
1911
accept rate: 0%


This seems to be part of PHP5.3s requirements. You would either have to downgrade PHP or update your code. You can also choose to suppress the error, however this may not solve the issue.

permanent link

answered 31 Aug '12, 17:25

johns
5.4k412
accept rate: 23%

^I understand this. But the fix would require that I know the timezone of the server as far as I can tell.

Therefore I will A) need to figure that out, and B) need to find out if the timezone is going to change (in theory) if there is not an environment variable that can be used to set the date.timezone setting.

Thanks

(01 Sep '12, 19:32) Mick

You may set the timezone to anything you would like to use, most people set it to the timezone their users are in, or have a mechanic which allow the user to choose or just use UTC. The servers timezone should be UTC, and we can check if you submit a support ticket. There is information on this thread about setting the timzeone in different places for PHP.

(01 Sep '12, 20:02) johns

Funny. I remember seeing that thread already. I was in a hurry to leave somewhere, and got the impression that it was preference thing, even though the opening post is definitely spot on...

In my case it seems like the cache might be failing because of a time mismatch, but maybe the problem (if there even is one) is the warning sometimes interfering with the headers.

It seems to work sometimes, but maybe the cache code is bypassed when it does work.

Can you please post the simplest fix (if not too much trouble) to explicitly set the PHP environment to UTC just for completeness sake?

If not I will post a fix as soon as I can convince myself that I've figured it out.

Thanks again.

(01 Sep '12, 23:37) Mick

According to the php documentation you can set it in a single line using:

date_default_timezone_set('UTC');

The "UTC" was shown in the list of timezones (under "Other") as one of several options. Hope that helps!

(02 Sep '12, 00:01) ryans ♦♦

Yes thanks. I will edit a good summary answer into the top post.

I found using date_default_timezone_set to be iffy with WordPress (this is maybe more of a WP thing; if other webapps take a more forward position on the matter) as the offending plugin code was executing before the wp-config file.

I wanted to edit php.ini, but I would like to only do so in one file account wide if possible. I can't seem to find the cgi-bin folder in my account anymore, where as I recall PHP was setup to run out of.

Is it possible the folder is hidden since I last looked? Or is it possible I've somehow ended up using the built in PHP setup?

Either way I remember there being a cgi folder that I can no longer find. I was thinking that might be the best place to add a php.ini file. But I have no clue. I apologize for not being more proactive about this thread :/

(03 Sep '12, 05:30) Mick

Hi,

The php.ini file needs to be in ~/webapps/<appname>/ - otherwise it won't be taken into account. It cannot be in the "cgi-bin" folder. PHP runs as CGI, but not really out of the cgi-bin folder, so you probably don't really need it. If you actually do need it, you can simply create it.

You cannot really have a php.ini file for the whole account - you need to create one php.ini file for each of your PHP apps.

(03 Sep '12, 05:36) todork

Thanks.

I was told my account was transferred to a different server a little while back. I found out because it (edited: temporarily) broke one of my databases.

I am nearly 100% positive that I had installed a custom PHP5.3 build in the cgi-bin folder. Since the folder is no longer there. Then I have to assume that someone made the decision for me to rearrange the account (because everything is working)

That may have been the only thing in the folder.

EDITED: This may only have become a problem since the aforementioned move. But I cannot say with certainty.

PS: It would be very handy if there was a default setting configured (UTC would probably be best) so that we don't have to edit this into a php.ini file for every single webapp folder. Just saying :)

(03 Sep '12, 22:43) Mick

^FYI: My account is on web55 just in case someone thinks having a default date.timezone for PHP5.3 is a good idea.

If for no other reason than the warnings issued by PHP (when not set) break all kinds of webpages.

(03 Sep '12, 22:55) Mick
showing 5 of 8 show 3 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×265
×3
×1
×1

question asked: 31 Aug '12, 05:22

question was seen: 9,174 times

last updated: 03 Sep '12, 22:55

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM