I have not found a solution to this online, because I think its the way i am using the date format.
Problem: I have a date format: 2013-06-07 This formate is created by the following:
$thedate = (string) substr($item->children('http://www.w3.org/2005/Atom')->updated,0,-15) . ' - ';
- Which is taken from a RSS feed, and trimmed so only the year, month and day is represented.
I then use this, to get the same, each is todays date:
$day = (string) date('Y-m-d');
So when I do a IF statement, the days should match, before it enters into the database:
if($day == $thedate) {
echo ($day . '\n' . $thedate);
$sql = "INSERT INTO rssFeed (date, stage, title, description, location, billtype, link) VALUES('".
$thedate ."','". $stage . "','" . $title . "', '" . $desc ."', '" . $location ."', '" . $billtype ."', '". $linkurl ."')";
//print_r($sql);
$inres = $mysqli->query($sql);
print_r($mysqli->error);
} else {
echo ('They do not match');
}'
It works fine without the IF statement, and I have printed both dates and they are identical, but, for whatever reason, the statement comes up as, not the same, and only 'They do not match' in console, or put into the database. No errors.
Any ideas ?
date
?date(Y-m-d)
is 10 chars long. Even when yoursubstr($x, 0, -15)
would be 10 chars long, you additionally append another 3 chars to$thedate
(' - '). Hence you compare a 10 vs. 13 chars string, which will fail.