Jump to content

Testing for dates: having issues with my test conditions


born2dive

Recommended Posts

I am a novice PHP coder, just started learning.

 

I am trying to display a message on my webpage that should be triggered by a date check.  The code is below (I removed all HTML tags for simplicity for now):

 

<?php

 

$m=date("m");

$d=date("d");

$y=date("Y");

 

$int_d = (int)$d;

 

//Thanksgiving

 

if ($m="11"&&$y="2010"&&$int_d>23&&$int_d<=28)

{

echo 'Happy Thanksgiving!';

}

 

//Holidays

 

if ($m="12"&&$y="2010"&&$int_d>=18&&$int_d<=31)

{

echo 'Happy Holidays!';

}

?>

 

I want each statement to be executed during the appropriate dates i.e. "Happy Thanksgiving" from 11/24/2010 to 11/28/2010, and "Happy Holidays" from 12/18/2010 to 12/31/2010.

 

The problem is that both statement are being executed regardless of the date conditions I use?

 

Thoughts?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.