jeff5656 Posted July 28, 2009 Share Posted July 28, 2009 My if statement seems to run even when it's not true: $check1_date = date("Y-m-d", strtotime($_POST['check1_date'])); echo "check1_date is ". $check1_date; echo: check1_date is 2009-09-09 if ($check1_date = '1969-12-31'){ echo "The statement is true check1date is: ". $check1_date; $check1_date = '2020-12-31'; echo "<br>Now check1date is: ". $check1_date; } Here's THAT output: The statement is true check1date is: 1969-12-31 Now check1date is: 2020-12-31 How did check1 date turn into 1969-12-31 when the previous echo proved that it was 2009-9-9?? I am very confused Link to comment https://forums.phpfreaks.com/topic/167836-solved-weird-date-problem-or-maybe-its-an-if-problem/ Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 you need two equal sings, not one: if ($check1_date == '1969-12-31'){ edit: but it's also better to check the timestamp IMO $check1_time = strtotime($_POST['check1_date']); if ($check1_time){ $check1_date = date("Y-m-d", $check1_time); echo "The statement is true check1date is: ". $check1_date; $check1_date = '2020-12-31'; echo "<br>Now check1date is: ". $check1_date; } Link to comment https://forums.phpfreaks.com/topic/167836-solved-weird-date-problem-or-maybe-its-an-if-problem/#findComment-885201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.