On 04 Jan 2012 at 21:59, Robert Williams <rewilli...@thesba.com> wrote: 

> On 1/4/12 14:34, "Tim Streater" <t...@clothears.org.uk> wrote:
>
>> As I hinted in my previous mail, client and server side of my app are
>> always on the user's machine. When the user starts the app, I create an
>> apache config file on the fly and run an instance of apache just for the
>> user. So I'm not messing with the standard OS X Web Sharing. For the same
>> reason, I don't want to start modifying or creating a php.ini file.
>
> In that case, you might consider setting it via the Apache config file
> that you're creating, which you can do with something like:
>
>        php_value date.timezone 'America/Phoenix'

OK.

> That'll have the same effect (and benefits) as setting it via php.ini.
>
>>> Hmm, just looked more carefully at the docs. I see I'm going to have to
>>> add a prefs setting so the user can tell my app what timezone they are
>>> in. I find it odd that the OS can't provide this information.
>
> Well, it typically can, or at least can make a guess at it. The problem is
> that it's not something you can rely on across different OSes, as some
> handle it differently, or less reliably, or not at all. Basically, the
> result is non-deterministic. It's for this reason that, as of 5.4, PHP
> won't even ask the OS but will always return UTC (and complain a bit) if
> something else hasn't been set. This way, you at least have a chance of
> consistent results.
>
> If you're only supporting OS X, you can have your script that generates
> the Apache config file retrieve the system time zone, and then use that
> value in the php_value setting. If the script is in PHP, you can do this:
>
>        $timeZone = `/usr/sbin/systemsetup -gettimezone`;
>
> Which just calls the systemsetup command line utility (basically, a CLI
> front-end to the settings controlled via System Preferences). Here's what
> that call returns when run on the command line on my system:
>
>        H012316WHPV:~ rewilliams$ systemsetup -gettimezone
>        Time Zone: America/Phoenix

That is a very helpful hint - thanks. Yes, it's OS X only at the moment as I 
don't have access to or a great interest in the other platforms.


Not sure if this has greatly help the OP though :-)

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to