SUMMARY:
BACKGROUND:
// PHP code
// AJAX VALUES PASSED FROM JAVASCRIPT FILE`
$s = $_GET['s'];
$q = floatval($_GET['q']);
$r = floatval($_GET['r']);
// FOR MYSQL
$sqlStarParty = "SELECT sp_name, sp_location, sp_date_start, sp_nights, sp_link, sp_comment
FROM star_party
WHERE
sp_date_start <= DATE_ADD(STR_TO_DATE('$s', '%Y-%m-%d'), INTERVAL 14 DAY)
AND
sp_date_start >= DATE_SUB(STR_TO_DATE('$s', '%Y-%m-%d'), INTERVAL 14 DAY)
AND
sp_latitude < ($q + 2) AND sp_latitude > ($q - 2)
AND
sp_longitude < ($r + 2) AND sp_longitude > ($r - 2)";
// TO BE ECHOED TO WEBPAGE
$resultStarParty = mysqli_query($conn, $sqlStarParty);
if (mysqli_num_rows($resultStarParty) > 0) {
while($row = mysqli_fetch_assoc($resultStarParty)) {
echo $row["sp_name"] . "<br/>";
echo "Location : " . $row["sp_location"] . "<br/>";
echo "Current year event start date: " . date_format(new DateTime($row["sp_date_start"]),'F, jS') . " for " . $row["sp_nights"] . " nights<br/>";
echo "Details and map: " . "<a href='".$row["sp_link"]."' target='_blank'>Website</a><br/>";
echo "<br></br>";
}
} // if no records match query - print 0 results
else {
echo "Sorry no star parties for this time and location";
}
EXPECTED RESULTS:
SOLUTION:
NEW DATE_TIME
.date_create
instead. Star party results are showing and correct.I think I've solved it. Where date_format(new DateTime($row["op_date"])
occured, I replaced with date_format(date_create($row["op_date"])
. Star Parties are showing correctly now. Hopefully this holds.