[PHP-DEV] Bug #14115 Updated: localtime() gives wrong year and month

2001-11-19 Thread rasmus

ID: 14115
Updated by: rasmus
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Bogus
Bug Type: Date/time related
Operating System: SuSE Linux 7.1
PHP Version: 4.0.6
New Comment:

tm_year is defined to be the number of years since 1900, so 101 is correct, and tm_mon 
starts with January = 0.  This is to match the libc function of the same name.  Do a 
man localtime on your system for proof.

Previous Comments:


[2001-11-19 08:37:25] [EMAIL PROTECTED]

/* 

Output from my attached PHP script:

-output starts here-
Server script path: /httpd/kunden/admbping/de/bigping/www/localtime_y2k.php


original 'localtime()' function:

tm_sec = 41
tm_min = 14
tm_hour = 14
tm_mday = 19
tm_mon = 10
tm_year = 101
tm_wday = 1
tm_yday = 322
tm_isdst = 0

my 'localtime_y2k()' function:

tm_sec = 41
tm_min = 14
tm_hour = 14
tm_mday = 19
tm_mon = 11
tm_year = 2001
tm_wday = 1
tm_yday = 322
tm_isdst = 0
-output ends here-


'date' command in bash:

localhost:/httpd/kunden/admbping/de/bigping/www # date
Mon Nov 19 14:14:57 CET 2001

*/

?
function localtime_y2k ($time, $is_ass) {
$t_arr = localtime ($time, $is_ass);
if ($is_ass == 0) {
$t_arr[5] = $t_arr[5] + 1900;
$t_arr[4] = $t_arr[4] + 1;
}
if ($is_ass == 1) {
$t_arr[tm_year] = $t_arr[tm_year] + 1900;
$t_arr[tm_mon] = $t_arr[tm_mon] + 1;
}
return $t_arr;
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd;
html lang=en_us
head
meta http-equiv=content-type content=text/html; charset=iso-8859-1
title
Untitled
/title
/head
body bgcolor=#FF
?
$the_time = time();
$timearray_old = localtime ($the_time, 1);
$timearray = localtime_y2k ($the_time, 1);
echo Server script path: .getenv (SCRIPT_FILENAME);
echo brbrbroriginal 'localtime()' function:brbr;
while (list ($key, $val) = each ($timearray_old)) {
echo $key = $valbr;
}
echo brbrbrmy 'localtime()' function:brbr;
while (list ($key, $val) = each ($timearray)) {
echo $key = $valbr;
}
? 
/body
/html






Edit this bug report at http://bugs.php.net/?id=14115edit=1


-- 
PHP Development 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-DEV] Bug #14115 Updated: localtime() gives wrong year and month

2001-11-19 Thread hholzgra

ID: 14115
Updated by: hholzgra
Reported By: [EMAIL PROTECTED]
Old Status: Bogus
Status: Open
Old Bug Type: Date/time related
Bug Type: Documentation problem
Operating System: SuSE Linux 7.1
PHP Version: 4.0.6
New Comment:

the manual does tell about the 1900 offset
for tm_year but not about tm_month starting
at 0

Previous Comments:


[2001-11-19 08:43:46] [EMAIL PROTECTED]

tm_year is defined to be the number of years since 1900, so 101 is correct, and tm_mon 
starts with January = 0.  This is to match the libc function of the same name.  Do a 
man localtime on your system for proof.



[2001-11-19 08:37:25] [EMAIL PROTECTED]

/* 

Output from my attached PHP script:

-output starts here-
Server script path: /httpd/kunden/admbping/de/bigping/www/localtime_y2k.php


original 'localtime()' function:

tm_sec = 41
tm_min = 14
tm_hour = 14
tm_mday = 19
tm_mon = 10
tm_year = 101
tm_wday = 1
tm_yday = 322
tm_isdst = 0

my 'localtime_y2k()' function:

tm_sec = 41
tm_min = 14
tm_hour = 14
tm_mday = 19
tm_mon = 11
tm_year = 2001
tm_wday = 1
tm_yday = 322
tm_isdst = 0
-output ends here-


'date' command in bash:

localhost:/httpd/kunden/admbping/de/bigping/www # date
Mon Nov 19 14:14:57 CET 2001

*/

?
function localtime_y2k ($time, $is_ass) {
$t_arr = localtime ($time, $is_ass);
if ($is_ass == 0) {
$t_arr[5] = $t_arr[5] + 1900;
$t_arr[4] = $t_arr[4] + 1;
}
if ($is_ass == 1) {
$t_arr[tm_year] = $t_arr[tm_year] + 1900;
$t_arr[tm_mon] = $t_arr[tm_mon] + 1;
}
return $t_arr;
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd;
html lang=en_us
head
meta http-equiv=content-type content=text/html; charset=iso-8859-1
title
Untitled
/title
/head
body bgcolor=#FF
?
$the_time = time();
$timearray_old = localtime ($the_time, 1);
$timearray = localtime_y2k ($the_time, 1);
echo Server script path: .getenv (SCRIPT_FILENAME);
echo brbrbroriginal 'localtime()' function:brbr;
while (list ($key, $val) = each ($timearray_old)) {
echo $key = $valbr;
}
echo brbrbrmy 'localtime()' function:brbr;
while (list ($key, $val) = each ($timearray)) {
echo $key = $valbr;
}
? 
/body
/html






Edit this bug report at http://bugs.php.net/?id=14115edit=1


-- 
PHP Development 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-DEV] Bug #14115 Updated: localtime() gives wrong year and month

2001-11-19 Thread hholzgra

ID: 14115
Updated by: hholzgra
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Closed
Bug Type: Documentation problem
Operating System: SuSE Linux 7.1
PHP Version: 4.0.6
New Comment:

added a note to phpdoc cvs

Previous Comments:


[2001-11-19 08:50:55] [EMAIL PROTECTED]

the manual does tell about the 1900 offset
for tm_year but not about tm_month starting
at 0



[2001-11-19 08:43:46] [EMAIL PROTECTED]

tm_year is defined to be the number of years since 1900, so 101 is correct, and tm_mon 
starts with January = 0.  This is to match the libc function of the same name.  Do a 
man localtime on your system for proof.



[2001-11-19 08:37:25] [EMAIL PROTECTED]

/* 

Output from my attached PHP script:

-output starts here-
Server script path: /httpd/kunden/admbping/de/bigping/www/localtime_y2k.php


original 'localtime()' function:

tm_sec = 41
tm_min = 14
tm_hour = 14
tm_mday = 19
tm_mon = 10
tm_year = 101
tm_wday = 1
tm_yday = 322
tm_isdst = 0

my 'localtime_y2k()' function:

tm_sec = 41
tm_min = 14
tm_hour = 14
tm_mday = 19
tm_mon = 11
tm_year = 2001
tm_wday = 1
tm_yday = 322
tm_isdst = 0
-output ends here-


'date' command in bash:

localhost:/httpd/kunden/admbping/de/bigping/www # date
Mon Nov 19 14:14:57 CET 2001

*/

?
function localtime_y2k ($time, $is_ass) {
$t_arr = localtime ($time, $is_ass);
if ($is_ass == 0) {
$t_arr[5] = $t_arr[5] + 1900;
$t_arr[4] = $t_arr[4] + 1;
}
if ($is_ass == 1) {
$t_arr[tm_year] = $t_arr[tm_year] + 1900;
$t_arr[tm_mon] = $t_arr[tm_mon] + 1;
}
return $t_arr;
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd;
html lang=en_us
head
meta http-equiv=content-type content=text/html; charset=iso-8859-1
title
Untitled
/title
/head
body bgcolor=#FF
?
$the_time = time();
$timearray_old = localtime ($the_time, 1);
$timearray = localtime_y2k ($the_time, 1);
echo Server script path: .getenv (SCRIPT_FILENAME);
echo brbrbroriginal 'localtime()' function:brbr;
while (list ($key, $val) = each ($timearray_old)) {
echo $key = $valbr;
}
echo brbrbrmy 'localtime()' function:brbr;
while (list ($key, $val) = each ($timearray)) {
echo $key = $valbr;
}
? 
/body
/html






Edit this bug report at http://bugs.php.net/?id=14115edit=1


-- 
PHP Development 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]