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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.