date() help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

date() help

Post by will83 »

Hi

Can anyone tell me whats wrong with this statement:

Code: Select all

<?php
if (date("m") == "Nov") {
echo "selected";
}
?>
Thanks

Will
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

date("m") returns the numeric month. Try:

Code: Select all

if (date("m") == 11) {
   //stuff 
}
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

date("m") will return numric representation of the month. What you need to do is user date("M")
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

ahhhhhh :P

Cheers
Post Reply