Running web scripts in your Timezone
From DreamHost
Many web programs log or show the time. If these programs use the local time, they'll be in the US West Coast Timezone that DreamHost uses for its servers.
However, it is easy to change that for your scripts.
Look for the .htaccess in your domain's directory (usually at $HOME/your.domain.name). If there isn't any, just create a new one (it's a plain text file).
Now, you have to know the name of your local timezone. This is usually in the form Continent/City (or Continent/Country/City). If you have a shell account, look for the system file /usr/share/zoneinfo/zone.tab, and find your City there. If your City isn't here, you should look for the largest City in your timezone.
For instance, if you live in or near Buenos Aires, Argentina (in South America), your timezone is found in a line like this:
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
- The first field is the ISO 3166 2-character country code. AR in the example stands for Argentina.
- The second field is the latitude and longitude of the zone's principal location in ISO 6709 sign-degrees-minutes-seconds format, either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS, first latitude (+ is north), then longitude (+ is east). In the example -3436-05287 stands for 34°36'S 52°87'W.
- The third field is the most important. This is the zone name, and the one you have to remember. America/Argentina/Buenos_Aires in the example.
- There may be a fourth field with comments that may help you identify other localities covered in the zone.
Now, having identified your timezone's name, add this line to the .htacccess file:
SetEnv TZ America/Argentina/Buenos_Aires
That's it! From now on, the scripts in your web server will run in your local time.
If still having issues this piece of code might help:
putenv("TZ=Europe/Bucharest");
This should be added to the php script that sends the date command. Remember to find out what your timezone is on the PHP Site.
Categories: Web | Htaccess | How-To | CGI

