Re: [PHP] timezone
[email protected] (Larry Martell)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CACwCsY5tpSuN=R3FVC7wgWnsohCSrYBqFs26eax3QDCWnuFokw@mail.gmail.com> |
On Mon, Apr 15, 2013 at 11:35 AM, Larry Martell <[email protected]> wrote: > On Mon, Apr 15, 2013 at 11:33 AM, Ashley Sheridan > <[email protected]> wrote: >> You don't know which timezone the server is in? That's what it wants. > > No, I don't - this app runs in different locations all over the world. I found some code at php.net that does this: date_default_timezone_set(@date_default_timezone_get()); $deftz = date('T'); And that is working for me and giving me what I need. >> Larry Martell <[email protected]> wrote: >>> >>> On Mon, Apr 15, 2013 at 11:17 AM, Jonathan Sundquist >>> <[email protected]> wrote: >>> >>> >>> >>>> On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell <[email protected]> >>>> wrote: >>>> >>>>> I have a client that has an app the runs with PHP 5.1.6. They want to >>>>> upgrade to 5.3.3. First issue I ran into, they have a line of code >>>>> that is: >>>>> >>>>> $deftz = date("T"); >>>>> >>>>> I'm getting this for that line: >>>>> >>>>> [Mon Apr 15 10:44:16 2013] [error] [client 10.7.14.21] PHP Warning: >>>>> date(): It is not safe to rely on the system's timezone settings. You >>>>> are *required* to use >>>>> the date.timezone setting or the >>>>> date_default_timezone_set() function. In case you used any of those >>>>> methods and you are still getting this warning, you most likely >>>>> misspelled the timezone identifier. We selected 'America/Denver' for >>>>> 'MDT/-6.0/DST' instead in /home/www/itrade-dev/defs.inc on line 349 >>>>> >>>>> So I changed it to >>>>> >>>>> $deftz = date.timezone; >>>>> >>>>> and now I get: >>>>> >>>>> [Mon Apr 15 10:49:35 2013] [error] [client 10.7.14.21] PHP Notice: >>>>> Use of undefined constant date - assumed 'date' in >>>>> /home/www/itrade-dev/defs.inc on line 349 >>>>> [Mon Apr 15 10:49:35 2013] [error] [client 10.7.14.21] PHP Notice: >>>>> Use of undefined constant timezone - assumed 'timezone' in >>>>> /home/www/itrade-dev/defs.inc on line 349 >>>>> >>>>> Why is this undefined? >>>> >>>> >>>> You need to set the default time zone in this fashion, >>>> >>>> http://php.net/manual/en/function.date-default-timezone-set.php >>> >>> >>> But I don't know the timezone - I'm trying to get it so I can convert >>> times I get from the database to a user requested timezone.