Problems with date() - what have I missed?
| From: | Jon Haworth | Date: | Tue, 13 Feb 2001 14:37:33 +0000 |
| Subject: | Problems with date() - what have I missed? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-39427@lists.php.net to get a copy of this message | ||
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