[PHP-DEV] Bug #12161 Updated: The date() function

2001-08-20 Thread sniper

ID: 12161
Updated by: sniper
Reported By: [EMAIL PROTECTED]
Old Status: Feedback
Status: Closed
Bug Type: Date/time related
Operating System: Windows 98
PHP Version: 4.0.6
New Comment:

Should be closed..


Previous Comments:


[2001-07-16 06:01:00] [EMAIL PROTECTED]

This is not a PHP bug, it is a bug in your code, related to
the use of preg_replace.
Example: printdate("ddd");

You're expecting:
Mon

You should be getting:
7on

Why?
Mon is becoming date("M")on, or something like it.
I don't know if this is what preg_replace SHOULD be
doing or not...it seems to be making multiple passes
until it can no longer replace anything. Could someone
who knows about preg_replace please verify whether this
is the correct behavior or not?

In the meantime, I fixed the userland code so that it performs
as you expected. You can find it at http://www.joeysmith.com/phpdate.phps



[2001-07-14 04:24:44] [EMAIL PROTECTED]

PHP Authors,

My names are James Hitz, author of http://jamhitz.tripod.com a website that provides 
free PHP tutorials.

I was creating a tutorial on user-defined functions and was working on one that 
accepts a string containing a date format (eg. dd-mmm-yy) and outputs  the date in the 
specified format.  The code is as follows:



On my Win 98 (Second Edition) system running php version 4.06, I evoked the following 
above functrion using  the following code snippet:

print printdate(" ddd, dd d m mm mmm  y yy yyy ");

This produced the following output:

Thurs12a01 Thu, 12 12 7 07 Jul Jul01 01 01 2001 2001

Aparrently, I expected this to have produced something like this:

Thursday Thu, 12 12 7 07 Jul July 01 01 2001 2001

The parsing of the date() function seems not to act 'normal'.  The documentation I 
have states as follows in regard to the date() function: 


date
(PHP 3, PHP 4 )

date -- Format a local time/date
Description

string date (string format [, int timestamp])


Returns a string formatted according to the given  
format string using the given timestamp or the current 
local time if no timestamp is given. 

The following characters are recognized in the format
string: 

d - day of the month, 2 digits with leading zeros; i.e.
 "01" to "31" 

D - day of the week, textual, 3 letters; i.e. "Fri" 

F - month, textual, long; i.e. "January" 

j - day of the month without leading zeros; i.e. "1"
to "31" 

l (lowercase 'L') - day of the week, textual, long;
   i.e. "Friday" 

m - month; i.e. "01" to "12" 

M - month, textual, 3 letters; i.e. "Jan" 

n - month without leading zeros; i.e. "1" to "12" 

r - RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200" 

Y - year, 4 digits; i.e. "1999" 

y - year, 2 digits; i.e. "99" 

z - day of the year; i.e. "0" to "365" 



Is this a bug in the code or a bug in the documentation?  Seems to me like one of 
those. Please advise. I am making a tutorial that will make use of the above function 
and would appreciate if you would tell me what to tell my audience.

The tutorials I am make are very good for all - even complete beginners, so you can 
bundle them in your PHP distributions, or you can point users to 
http://jamhitz.tripod.com.  All tutorials are free.

Thanking you.
James N. Hitz
[EMAIL PROTECTED]






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


-- 
PHP Development Mailing List 
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 #12161 Updated: The date() function

2001-07-16 Thread joey

ID: 12161
Updated by: joey
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Feedback
Bug Type: Unknown/Other Function
Operating System: Windows 98
PHP Version: 4.0.6
New Comment:

This is not a PHP bug, it is a bug in your code, related to
the use of preg_replace.
Example: printdate("ddd");

You're expecting:
Mon

You should be getting:
7on

Why?
Mon is becoming date("M")on, or something like it.
I don't know if this is what preg_replace SHOULD be
doing or not...it seems to be making multiple passes
until it can no longer replace anything. Could someone
who knows about preg_replace please verify whether this
is the correct behavior or not?

In the meantime, I fixed the userland code so that it performs
as you expected. You can find it at http://www.joeysmith.com/phpdate.phps

Previous Comments:


[2001-07-14 04:24:44] [EMAIL PROTECTED]

PHP Authors,

My names are James Hitz, author of http://jamhitz.tripod.com a website that provides 
free PHP tutorials.

I was creating a tutorial on user-defined functions and was working on one that 
accepts a string containing a date format (eg. dd-mmm-yy) and outputs  the date in the 
specified format.  The code is as follows:



On my Win 98 (Second Edition) system running php version 4.06, I evoked the following 
above functrion using  the following code snippet:

print printdate(" ddd, dd d m mm mmm  y yy yyy ");

This produced the following output:

Thurs12a01 Thu, 12 12 7 07 Jul Jul01 01 01 2001 2001

Aparrently, I expected this to have produced something like this:

Thursday Thu, 12 12 7 07 Jul July 01 01 2001 2001

The parsing of the date() function seems not to act 'normal'.  The documentation I 
have states as follows in regard to the date() function: 


date
(PHP 3, PHP 4 )

date -- Format a local time/date
Description

string date (string format [, int timestamp])


Returns a string formatted according to the given  
format string using the given timestamp or the current 
local time if no timestamp is given. 

The following characters are recognized in the format
string: 

d - day of the month, 2 digits with leading zeros; i.e.
 "01" to "31" 

D - day of the week, textual, 3 letters; i.e. "Fri" 

F - month, textual, long; i.e. "January" 

j - day of the month without leading zeros; i.e. "1"
to "31" 

l (lowercase 'L') - day of the week, textual, long;
   i.e. "Friday" 

m - month; i.e. "01" to "12" 

M - month, textual, 3 letters; i.e. "Jan" 

n - month without leading zeros; i.e. "1" to "12" 

r - RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200" 

Y - year, 4 digits; i.e. "1999" 

y - year, 2 digits; i.e. "99" 

z - day of the year; i.e. "0" to "365" 



Is this a bug in the code or a bug in the documentation?  Seems to me like one of 
those. Please advise. I am making a tutorial that will make use of the above function 
and would appreciate if you would tell me what to tell my audience.

The tutorials I am make are very good for all - even complete beginners, so you can 
bundle them in your PHP distributions, or you can point users to 
http://jamhitz.tripod.com.  All tutorials are free.

Thanking you.
James N. Hitz
[EMAIL PROTECTED]






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


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]