Don't worry. False alarm. My bad. (etc)

Hint for people experiencing a problem like this in the future: when passing
variables to mktime(), ensure $cmonth=3 and not $cmonth="March", I find it
helps a *lot* :-)

Moral to the story: when having difficulties, echo your variables to the
screen....

Cheers
Jon


-----Original Message-----
From: Jon Haworth [mailto:[EMAIL PROTECTED]]
Sent: 13 February 2001 14:38
To: '[EMAIL PROTECTED]'
Subject: [PHP] Problems with date() - what have I missed?


Hi list.

I have a strange problem with a PHP script (WinNT/Apache/PHP4/MySQL).

The line of code

        $dayname = date("D", mktime(0,0,0,$cmonth,$eventdate,$cyear));

should, if I understand it correctly, fill the variable $dayname with the
three-letter abbreviation of the day of the week for the date I supply.

I have $cmonth=3, $eventdate=26, and $cyear=2001. I would expect this to put
"Mon" in $dayname, given that March 26th 2001 is a Monday. However, my
script displays "Tue" which is a bit peculiar.

As if that weren't enough, it isn't consistent in getting the days wrong.
For example:

November 30th 2000 was a Thursday. It gets this right.
December 14th 2000 was a Thursday. It says it was a Tuesday.
January 11th 2001 was a Thursday. It says it was a Monday.
February 11th 2001 was a Sunday. It says it was a Monday.
March 26th 2001 is a Monday. It says it is a Tuesday.

What am I doing wrong? Is it something to do with last year (officially it
wasn't a leap year but as 2000 is divisible by 4, many people thought it
should be)? I'm in GMT so unless it's a BST thing I'm not being affected by
a local time zone.

All help gratefully appreciated....

Cheers
Jon


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

Reply via email to