Time in a PASE environment!

I have seen numerous posts on the ZEND PHP forums regarding the time not being correct in the output generated by the PHP date() function. So I thought I would check it out for myself.

First pass I simply ran the QP2TERM program and ran the date command in the terminal environment, it came back with the right date and time! I read through the manuals a bit (google is marvelous!) to see what could be the problem. I got a number of hits and after reviewing the returned content I posted back on the forum about setting the TZ environment variable.

Here are a couple of notes I made

OS/400 PASE environment variables are independent of ILE environment variables. Setting a variable in one environment has no effect on the other environment, but several system interfaces allow you to copy variables between environments:

Time-of-day information in an OS/400 PASE program depends on the value of OS/400 PASE environment variable TZ, which provides information about timezone name and offset from UTC (Universal Coorodinated Time). For example, the correct TZ setting for Central Time in the USA is TZ=CST6CDT. See AIX documentation for more information about environment varble TZ

(the spelling mistakes are not mine this time!)

As the time in QP2TERM seemed to be right I thought I was not having the same problem, so I added a bit of code to a test page to test the PHP values returned.
echo date('l dS of F Y h:i:s A');
This should have returned the right time but I was 5 hours out, it was obviously returning the GMT time. So I set an environment variable TZ with a value of ‘EST5EDT’ and ran the page again! No change. I was using the WRKENVVAR to add the variable, I didnt prompt the command so I only got the *JOB ENVVAR’s. (Remember to prompt the WRKENVAR command if you want to work with *SYS level variables.) It still didnt work so I dug a little further to find that the i5 version of the AIX TZ variable is PASE_TZ. So I set this to the right value using ADDENVVAR ENVVAR(PASE_TZ) VALUE('EST5EDT') LEVEL(*SYS) but I still didnt get the right results!

So after a little more reading I found a few lines hidden in the depths of the text which seemed to imply the variables are loaded on program start up, so as the Zend PHP server was running all the time it could be the problem. Stopping the subsystem (I decided stopping the subsystem would be more effective than just the HTTP servers) and starting it again fixed the problem. I now have a php script returning the correct date and time!

Here is a link to the forum post in case your interested.
Date problem post

Happy hunting!

Chris…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.