Even lower: userconfig.php and setting the timezone

In an earlier post, I talked about low-level customization with userconfig.cfg. Well, there's actually an even lower level. That would be userconfig.php.

The principle is simple: userconfig.php is a PHP file that, if it exists, is loaded and executed before anything else. So, in other words, this is the place to put any code you need to modify your PHP configuration or things of that manner.

One handy use of this is setting the time zone. You might want to do that if you're like me and use a web host that's in a different time zone than you are. Sadly, PHP 4 doesn't provide an easy way to format dates to a different time zone. However, if you're using a typical Linux/Apache server, you can simply set an environment variable to take care of this.

To do this, you can just create a userconfig.php file in your userdata and add the following text to it (substituting your own timesone, or course):
<?php
putenv("TZ=US/Eastern");
?>

If you need to add any other special PHP code, such as ini_set() calls, it would go between the PHP tags. Just keep in mind that you can't have any characters or blank space (including blank lines) outside the PHP tags.

Of course, since this file is raw PHP code, it's not a good idea to mess with it too much unless you really know what you're doing. In fact, it's probably a bad idea to use it if you don't have a working knowledge of PHP. It's really only there to make things easier for those rare occasions where you really, genuinely do need to add some code when a page loads.

You can reply to this entry by leaving a comment below. You can send TrackBack pings to this URL. This entry accepts Pingbacks from other blogs. You can follow comments on this entry by subscribing to the RSS feed.

Add your comments #

A comment body is required. No HTML code allowed. URLs starting with http:// or ftp:// will be automatically converted to hyperlinks.