we're stuck with PHP 4 and i'm needing to obtain the timezone from the unix box.
i try getenv('TZ') but it always comes up empty.
is there another way to read the timezone from the unix box?
| SitePoint Sponsor |



we're stuck with PHP 4 and i'm needing to obtain the timezone from the unix box.
i try getenv('TZ') but it always comes up empty.
is there another way to read the timezone from the unix box?
date()
Although, php may not neccesarily be set to the same timezone as the OS.



Some of the PHP date options might be available to PHP4, just run them and see if they work.
If I may ask, how exactly do you become stuck with PHP4? Version 5 has been stable for around 5 years now.PHP Code:$ php -r "echo date('e * O * T * Z') . \"\n\";"
America/Denver * -0700 * MST * -25200
Brad Hanson, Web Applications & Scalability Specialist
► Is your website outgrowing its current hosting solution?
► PM me for a FREE scalability consult!
► USA Based: Available by Phone, Skype, AIM, and E-mail.



it's just what we have on our production units and it's not up to me to decide what version we have installed and we're stuck with it.
unfortunately the 'e' in date() is a 5+ addition. :/ that would be great for what i need.
any idea why when i call upon getenv('TZ') it doesn't return the correct timezone?
it SHOULD be pulling in America/New_York.



Whoops, I forgot "e" is PHP5, did you try the others though? O T and Z?
Brad Hanson, Web Applications & Scalability Specialist
► Is your website outgrowing its current hosting solution?
► PM me for a FREE scalability consult!
► USA Based: Available by Phone, Skype, AIM, and E-mail.



they want the list that the user chooses from to have the countries' (as seen when using 'e') names in them.
not sure the best way around it.



sooooo... anyone have any idea why getenv('TZ') doesn't work just how date('e') in PHP 5 does?
i can only get getenv('TZ') to work after i've set TZ, which sucks.



If your boss isn't the one actually coding the software on your production server, then he also probably won't know that PHP should be updated unless you tell him.
You could make an incredibly strong case to bring to him. It's probably costing your company money for you to be screwing around with PHP4 when your productivity could be so much higher with PHP5. And all for what... not typing `yum update php`?
There's no excuse for any applications in active development to still be using PHP4, none at all. This is something you should definitely talk to him about.
If not, then you're going to need to maintain a database of timezones and read from that. The built in timezone extension is built from a list acquired here: ftp://elsie.nci.nih.gov/pub/
Edit:
An alternative might be using a different format for your drop down menu.
I've seen sites use something like:
What time is it now?
===============
...
11:15 AM
12:15 PM
1:15 PM
2:15 PM
...
With success
Brad Hanson, Web Applications & Scalability Specialist
► Is your website outgrowing its current hosting solution?
► PM me for a FREE scalability consult!
► USA Based: Available by Phone, Skype, AIM, and E-mail.



i'm just going to run this unix command. it actually pulls the info i need.
ls -l /etc/localtime



Tryand see if it displays FALSE.PHP Code:echo var_dump(getenv('TZ'));
[read: PHP Sec. | CSRF | PCRE Mods | Encryption | Form Proc. | File Val.]
[tools: PHPEd | PHP Docs | jQuery | CI | SwiftMailer | CKEditor | reCAPTCHA]
Bookmarks