When I am processing two dates within a php script, the output that is rendered is not what is being expected.
For example when I run
<?php
date_default_timezone_set('EST');
$firstday = date('Y-m-01');
$today = date('Y-m-d');
if ($firstday = $today)
echo "Today is the 1st <br/>";
else
echo "Today is not the 1st <br/>";
echo'The first of the month is: '. $firstday . '<br/>';
echo'Today is: '. $today . '<br/>';
?>
The output is:
Today is the 1st
The first of the month is: 2014-07-30
Today is: 2014-07-30
When it should be
Today is not the 1st.
The first of the month is: 2014-07-01
Today is: 2014-07-30
However when I run one of the date()s at a time, I get that $today = 2014-07-30 and I get $firstdate = 2014-07-01 but not when I run them at the same time.
Can you not run two date() functions at the same time in PHP or do I have it formatted wrong?
if ($firstday = $today)<-- you use=instead of==.