[PHP] how to get consistent UTC from gmmktime (w/o dst-offset) ????

2002-03-26 Thread Patrick Sibenaler



hi.

i'm storing events in a mysql-db, using epoch timestamps to pinpoint the 
exact date/time for an event.

so far, I have been using localtime, being aware that there are
inconsistencies 
in the number of epoch-seconds, when DST flips on and off. nevertheless, that 
works fine as long as you stick to mktime() and date() for all the date-math 
as in mktime(0,0,0,$month,$day+$offset,$year)

but as soon as you leave php and have to do some calculation in javascript, 
you will encounter functions that behave differently on the pc and mac 
platforms. so you have to revert back to the 'add 86400-seconds' to calculate 
the next day.

so I thought it would be nice to have all the timestamps as linear, 
non-dst-epoch-seconds (UTC) and I went into the gmmktime() and gmdate() 
functions, assuming they would do the math in a linear second-based timespace 
(in GMT, without DST). That seems to be the case for the output of 'gmdate', 
that remains correct, if you count up seconds across the DST boundary (see 
second example).

but it seems that there is no way to calculate the gmt-epoch for a given 
date using gmmktime without having to add/subtract the TZ manually. gmmktime
will always take your local DST-settings into calculation and upon conversion 
back with gmdate, you will be off by the number of hours of your timezone.
I thought gmmktime() would handle this as if the computer would be in
Greenwich 
(TZ=0), which would then leave us with the two functions encoding/decoding 
consistently.

anyone having solved this properly?

-
print count days:br\n;
for($day=0; $day7; $day++){
$timgmt = gmmktime(0,0,0,3,28+$day,2002);
$timloc = mktime(0,0,0,3,28+$day,2002);
print $timgmt . = gmmktim epoch -  . gmdate(D d.m.Y H:i I,$timgmt) .
br\n;
print $timloc . = mktim epoch -  . date(D d.m.Y H:i  I,$timloc) .
br\n;
print BR\n;
}


count days:
101727= gmmktim epoch - Wed 27.03.2002 23:00 0
101727= mktim epoch - Thu 28.03.2002 00:00 0

1017356400= gmmktim epoch - Thu 28.03.2002 23:00 0
1017356400= mktim epoch - Fri 29.03.2002 00:00 0

1017442800= gmmktim epoch - Fri 29.03.2002 23:00 0
1017442800= mktim epoch - Sat 30.03.2002 00:00 0

1017529200= gmmktim epoch - Sat 30.03.2002 23:00 0
1017529200= mktim epoch - Sun 31.03.2002 00:00 0
dst on
1017619200= gmmktim epoch - Mon 01.04.2002 00:00 0   off by one hour due to
DST
1017612000= mktim epoch - Mon 01.04.2002 00:00 1

1017705600= gmmktim epoch - Tue 02.04.2002 00:00 0
1017698400= mktim epoch - Tue 02.04.2002 00:00 1

1017792000= gmmktim epoch - Wed 03.04.2002 00:00 0
1017784800= mktim epoch - Wed 03.04.2002 00:00 1


-
print count seconds:br\n;
$baseepoch = $timloc = mktime(0,0,0,3,28,2002);
for($day=0; $day7; $day++){
$epochnow = $baseepoch + (60 * 60 * 24 * $day);
print $epochnow . = gmmktim epoch -  . gmdate(D d.m.Y H:i I,$epochnow) .
br\n;
print $epochnow . = mktim epoch -  . date(D d.m.Y H:i  I,$epochnow) .
br\n;
print BR\n;
}

count seconds:
101727= gmmktim epoch - Wed 27.03.2002 23:00 0   consistent, but off by
-1 (your TZ)
101727= mktim epoch - Thu 28.03.2002 00:00 0

1017356400= gmmktim epoch - Thu 28.03.2002 23:00 0
1017356400= mktim epoch - Fri 29.03.2002 00:00 0

1017442800= gmmktim epoch - Fri 29.03.2002 23:00 0
1017442800= mktim epoch - Sat 30.03.2002 00:00 0

1017529200= gmmktim epoch - Sat 30.03.2002 23:00 0
1017529200= mktim epoch - Sun 31.03.2002 00:00 0

1017615600= gmmktim epoch - Sun 31.03.2002 23:00 0
1017615600= mktim epoch - Mon 01.04.2002 01:00 1

1017702000= gmmktim epoch - Mon 01.04.2002 23:00 0
1017702000= mktim epoch - Tue 02.04.2002 01:00 1

1017788400= gmmktim epoch - Tue 02.04.2002 23:00 0
1017788400= mktim epoch - Wed 03.04.2002 01:00 1

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




[PHP] help: form variables have CR/LF ?

2001-09-21 Thread Patrick Sibenaler




Does anyone know what is going wrong, when all of a sudden, the 
content of PHP global variables that are generated from a POSTED 
form, have a CR/LF prepended?

That means, looking at a field 'name' where 'john' was typed in, 
I'm getting a variable $name with the content

'
john'

instead of 'john'

Anyone seen this I found that it only happens with the POST 
method. GET works fine (but I cannot use that).

Any help is greatly appreciated.


greets.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] help: form fields have CR/LF on submit

2001-09-21 Thread Patrick Sibenaler



I submit a form with multipart/form-data, where a field 'name' 
contains let's say 'john'. On submit, I do get the expected global 
$name -variable but the content has a CR/LF or /n character in front 
of the actual content, like:

'
john'

instead of 'john'.

Can anyone advise on this??? The script has been running on another 
machine so far without any problems, but upon moving it to a new 
server with php4, I started getting this bug.

thanks  greets

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help: form fields have CR/LF on submit

2001-09-21 Thread Patrick Sibenaler



PHP 4.0.4pl1 is used here on an Apache 1.3.14 on a RedHat Linux 7.0
Kernel 2.2.17





Tamas Arpad wrote:
 
 On Friday 21 September 2001 17:17, Patrick Sibenaler wrote:
  I submit a form with multipart/form-data, where a field 'name'
  contains let's say 'john'. On submit, I do get the expected global
  $name -variable but the content has a CR/LF or /n character in
  front of the actual content, like:
 Hi,
 As I wrote before for me this was caused by Konqueror. But I think I
 read it on bugs.php.net (about half year ago) that there was a bug in
 an older (but still v4) PHP, maybe in 4.02 that causes the same
 effect. So if you have an older php on the other server try to
 upgrade it to the newest version.
 Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help: form fields have CR/LF on submit

2001-09-21 Thread Patrick Sibenaler




PHP 4.0.4pl1 is used here on an Apache 1.3.14 on a RedHat Linux 7.0
Kernel 2.2.17





Tamas Arpad wrote:
 
 On Friday 21 September 2001 17:17, Patrick Sibenaler wrote:
  I submit a form with multipart/form-data, where a field 'name'
  contains let's say 'john'. On submit, I do get the expected global
  $name -variable but the content has a CR/LF or /n character in
  front of the actual content, like:
 Hi,
 As I wrote before for me this was caused by Konqueror. But I think I
 read it on bugs.php.net (about half year ago) that there was a bug in
 an older (but still v4) PHP, maybe in 4.02 that causes the same
 effect. So if you have an older php on the other server try to
 upgrade it to the newest version.
 Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help: form fields have CR/LF on submit

2001-09-21 Thread Patrick Sibenaler




PHP 4.0.4pl1 is used here on an Apache 1.3.14 on a RedHat Linux 7.0
Kernel 2.2.17



Tamas Arpad wrote:
 
 On Friday 21 September 2001 17:17, Patrick Sibenaler wrote:
  I submit a form with multipart/form-data, where a field 'name'
  contains let's say 'john'. On submit, I do get the expected global
  $name -variable but the content has a CR/LF or /n character in
  front of the actual content, like:
 Hi,
 As I wrote before for me this was caused by Konqueror. But I think I
 read it on bugs.php.net (about half year ago) that there was a bug in
 an older (but still v4) PHP, maybe in 4.02 that causes the same
 effect. So if you have an older php on the other server try to
 upgrade it to the newest version.
 Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help: form fields have CR/LF on submit

2001-09-21 Thread Patrick Sibenaler




Before others wate their time on this:
The bug has officially been filed for RedHat 7.0 and php 4.0.4pl1:

http://bugs.php.net/index.php?id=8966


thanks tamas.




Tamas Arpad wrote:
 
 On Friday 21 September 2001 17:17, Patrick Sibenaler wrote:
  I submit a form with multipart/form-data, where a field 'name'
  contains let's say 'john'. On submit, I do get the expected global
  $name -variable but the content has a CR/LF or /n character in
  front of the actual content, like:
 Hi,
 As I wrote before for me this was caused by Konqueror. But I think I
 read it on bugs.php.net (about half year ago) that there was a bug in
 an older (but still v4) PHP, maybe in 4.02 that causes the same
 effect. So if you have an older php on the other server try to
 upgrade it to the newest version.
 Arpi

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] how do i get url: response codes?

2001-07-12 Thread Patrick Sibenaler



I've tried for a while now to figure out how to test from within php 
if a url (http://xxx/file.html) is present and what error code is 
returned (200,201,202,404, etc...)

the only way to test a url seems to be to open
file('http://xxx/file.html') 
and see if it can be done. but that completely suppresses any error 
codes and especially redirects. Has anyone figured out how to pull out 
http error codes using php?


greets./

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] RE: [PHP-WIN] php XML output in IE: no display

2001-07-09 Thread Patrick Sibenaler




 IE does some intelligent guessing based on filename extension that will
 override headers. If you send enough headers in the right sequence you can
 get it to work right - with a weird name if you want to save it and
 sometimes a double query on whether or not you want to save it. Tricking it
 via PATH_INFO URLs works without any weird problems.

I've just tried to fool IE into any mime (text/plain, image/gif, 
foo/bar) with the same content but it keeps ignoring it all on IE.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]