php-general Digest 15 Apr 2013 17:14:22 -0000 Issue 8196

2013-04-15 Thread php-general-digest-help

php-general Digest 15 Apr 2013 17:14:22 - Issue 8196

Topics (messages 320848 through 320848):

timezone
320848 by: Larry Martell

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
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?
---End Message---


[PHP] timezone

2013-04-15 Thread Larry Martell
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?

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



Re: [PHP] timezone

2013-04-15 Thread Jonathan Sundquist
On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell larry.mart...@gmail.comwrote:

 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?

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

  You need to set the default time zone in this fashion,

http://php.net/manual/en/function.date-default-timezone-set.php


Re: [PHP] timezone

2013-04-15 Thread Larry Martell
On Mon, Apr 15, 2013 at 11:17 AM, Jonathan Sundquist
jsundqu...@gmail.com wrote:



 On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell larry.mart...@gmail.com
 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.

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



Re: [PHP] timezone

2013-04-15 Thread Ashley Sheridan
You don't know which timezone the server is in? That's what it wants.

Larry Martell larry.mart...@gmail.com wrote:

On Mon, Apr 15, 2013 at 11:17 AM, Jonathan Sundquist
jsundqu...@gmail.com wrote:



 On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell
larry.mart...@gmail.com
 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.

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

Thanks,
Ash
http://www.ashleysheridan.co.uk

Re: [PHP] timezone

2013-04-15 Thread Larry Martell
On Mon, Apr 15, 2013 at 11:33 AM, Ashley Sheridan
a...@ashleysheridan.co.uk 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.


 Larry Martell larry.mart...@gmail.com wrote:

 On Mon, Apr 15, 2013 at 11:17 AM, Jonathan Sundquist
 jsundqu...@gmail.com wrote:



 On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell larry.mart...@gmail.com
 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.

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



Re: [PHP] timezone

2013-04-15 Thread Larry Martell
On Mon, Apr 15, 2013 at 11:35 AM, Larry Martell larry.mart...@gmail.com wrote:
 On Mon, Apr 15, 2013 at 11:33 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk 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 larry.mart...@gmail.com wrote:

 On Mon, Apr 15, 2013 at 11:17 AM, Jonathan Sundquist
 jsundqu...@gmail.com wrote:



 On Mon, Apr 15, 2013 at 12:14 PM, Larry Martell larry.mart...@gmail.com
 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.

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



Re: [PHP] timezone

2013-04-15 Thread Lester Caine

Larry Martell wrote:

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.


But do you ACTUALLY know what time zone is stored IN the database? What if te 
database was from another server?


One of the 'standards' adopted when working world wide is to ensure what is 
stored IN the database is always UTC based. So you can always compare times on 
the same consistent base. The only time you need the offset is to display a 
local time, and that is either the time local to the server, or the time local 
to the client.


The 'default' timezone is not necessarily the right one in either case ;)

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] timezone

2013-04-15 Thread Larry Martell
On Mon, Apr 15, 2013 at 1:59 PM, Lester Caine les...@lsces.co.uk wrote:
 Larry Martell wrote:

 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.


 But do you ACTUALLY know what time zone is stored IN the database? What if
 te database was from another server?

 One of the 'standards' adopted when working world wide is to ensure what is
 stored IN the database is always UTC based. So you can always compare times
 on the same consistent base. The only time you need the offset is to display
 a local time, and that is either the time local to the server, or the time
 local to the client.

 The 'default' timezone is not necessarily the right one in either case ;)

I misspoke - the data in the db is in UTC. This is used to covert the
time of day on the server to the user's local timezone.

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



Re: [PHP] timezone

2013-04-15 Thread Maciek Sokolewicz

On 15-4-2013 22:12, Larry Martell wrote:

On Mon, Apr 15, 2013 at 1:59 PM, Lester Caine les...@lsces.co.uk wrote:

Larry Martell wrote:


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.



But do you ACTUALLY know what time zone is stored IN the database? What if
te database was from another server?

One of the 'standards' adopted when working world wide is to ensure what is
stored IN the database is always UTC based. So you can always compare times
on the same consistent base. The only time you need the offset is to display
a local time, and that is either the time local to the server, or the time
local to the client.

The 'default' timezone is not necessarily the right one in either case ;)


I misspoke - the data in the db is in UTC. This is used to covert the
time of day on the server to the user's local timezone.



You are aware that the code you used is really bad practice, right? 
You're basically hiding the error no default timezone set by getting 
the default timezone, which returns an error; surpressing that error, 
providing the date_default_timezone_set function with the default value 
of date_default_timezone_get if none is defined (which there should!!), 
being UTC.


So in short, you're saying set the default timezone to the default 
timezone if no timezone is set, which I know there is not. That's very 
hard to understand for future programmers reading your code. Why not 
just set date_default_timezone_set('UTC'). It's clear, resolves the 
warning and works perfectly, instead of relying on vague defaults 
somewhere, in the hope they're set right.


On a sidenote; the reason why your original fix did not work:
$deftz = date.timezone;
Is because date.timezone is an ini setting. Not valid PHP code. And the 
error actually tells you you need to SET date.timezone, not set a 
variable TO the ini setting. In other words, you wanted date.timezone = 
UTC instead of $tz = date.timezone (which makes no sense anyway)


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



Re: [PHP] timezone

2013-04-15 Thread Larry Martell
On Mon, Apr 15, 2013 at 2:57 PM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
 On 15-4-2013 22:12, Larry Martell wrote:

 On Mon, Apr 15, 2013 at 1:59 PM, Lester Caine les...@lsces.co.uk wrote:

 Larry Martell wrote:


 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.



 But do you ACTUALLY know what time zone is stored IN the database? What
 if
 te database was from another server?

 One of the 'standards' adopted when working world wide is to ensure what
 is
 stored IN the database is always UTC based. So you can always compare
 times
 on the same consistent base. The only time you need the offset is to
 display
 a local time, and that is either the time local to the server, or the
 time
 local to the client.

 The 'default' timezone is not necessarily the right one in either case ;)


 I misspoke - the data in the db is in UTC. This is used to covert the
 time of day on the server to the user's local timezone.


 You are aware that the code you used is really bad practice, right? You're
 basically hiding the error no default timezone set by getting the default
 timezone, which returns an error; surpressing that error, providing the
 date_default_timezone_set function with the default value of
 date_default_timezone_get if none is defined (which there should!!), being
 UTC.

 So in short, you're saying set the default timezone to the default timezone
 if no timezone is set, which I know there is not. That's very hard to
 understand for future programmers reading your code. Why not just set
 date_default_timezone_set('UTC'). It's clear, resolves the warning and
 works perfectly, instead of relying on vague defaults somewhere, in the hope
 they're set right.

 On a sidenote; the reason why your original fix did not work:
 $deftz = date.timezone;
 Is because date.timezone is an ini setting. Not valid PHP code. And the
 error actually tells you you need to SET date.timezone, not set a variable
 TO the ini setting. In other words, you wanted date.timezone = UTC instead
 of $tz = date.timezone (which makes no sense anyway)

But UCT is not the timezone. When this app runs in New Mexico (where I
am) it's Mountain time. When it runs in NY it's Eastern. When it runs
in Tokyo it's JST, etc. The user has the option of setting the
timezone all times are displayed in. They can select any timezone
regardless of where they are. The app displays the last update time in
the user selected TZ. So I have to convert the time I get from the
server to that.

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



Re: [PHP] timezone

2013-04-15 Thread Maciek Sokolewicz
On 15 April 2013 23:06, Larry Martell la...@software-horizons.com wrote:

  But UCT is not the timezone. When this app runs in New Mexico (where I
 am) it's Mountain time. When it runs in NY it's Eastern. When it runs
 in Tokyo it's JST, etc. The user has the option of setting the
 timezone all times are displayed in. They can select any timezone
 regardless of where they are. The app displays the last update time in
 the user selected TZ. So I have to convert the time I get from the
 server to that.


Most servers provide UTC time regardless of the exact timezone they are
situated in and then leave it to the user to show it in the right timezone
to the user. The timezone you want to set is the timezone you GET the time
in. Not necesserily the timezone your device resides in.


Re: [PHP] timezone

2013-04-15 Thread Stuart Dallas
On Mon, Apr 15, 2013 at 10:06 PM, Larry Martell 
la...@software-horizons.com=mailto:la...@software-horizons.com; wrote:
On Mon, Apr 15, 2013 at 2:57 PM, Maciek Sokolewicz
 wrote:
 On 15-4-2013 22:12, Larry Martell wrote:

 On Mon, Apr 15, 2013 at 1:59 PM, Lester Caine  wrote:

 Larry Martell wrote:


 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.



 But do you ACTUALLY know what time zone is stored IN the database? What
 if
 te database was from another server?

 One of the 'standards' adopted when working world wide is to ensure what
 is
 stored IN the database is always UTC based. So you can always compare
 times
 on the same consistent base. The only time you need the offset is to
 display
 a local time, and that is either the time local to the server, or the
 time
 local to the client.

 The 'default' timezone is not necessarily the right one in either case ;)


 I misspoke - the data in the db is in UTC. This is used to covert the
 time of day on the server to the user's local timezone.


 You are aware that the code you used is really bad practice, right? You're
 basically hiding the error no default timezone set by getting the default
 timezone, which returns an error; surpressing that error, providing the
 date_default_timezone_set function with the default value of
 date_default_timezone_get if none is defined (which there should!!), being
 UTC.

 So in short, you're saying set the default timezone to the default timezone
 if no timezone is set, which I know there is not. That's very hard to
 understand for future programmers reading your code. Why not just set
 date_default_timezone_set('UTC'). It's clear, resolves the warning and
 works perfectly, instead of relying on vague defaults somewhere, in the hope
 they're set right.

 On a sidenote; the reason why your original fix did not work:
 $deftz = date.timezone;
 Is because date.timezone is an ini setting. Not valid PHP code. And the
 error actually tells you you need to SET date.timezone, not set a variable
 TO the ini setting. In other words, you wanted date.timezone = UTC instead
 of $tz = date.timezone (which makes no sense anyway)

But UCT is not the timezone. When this app runs in New Mexico (where I
am) it's Mountain time. When it runs in NY it's Eastern. When it runs
in Tokyo it's JST, etc. The user has the option of setting the
timezone all times are displayed in. They can select any timezone
regardless of where they are. The app displays the last update time in
the user selected TZ. So I have to convert the time I get from the
server to th...@lsces.co.uk@gmail.com@gmail.com

You don't need to convert anything! Store as unix timestamps, and call 
date_default_timezone_set with the user's selection before you use any other 
date-related functions and everything will just work. This is not as hard as 
everyone seems to think!​​​-Stuart


​—
Sent from my leaf 
blo...@gmail.com@lsces.co.uk@gmail.com​@lsces.co.uk@gmail.com