I'm trying to populate a list menu where the selections will either be in the past or the future based on the gamedate.
i want 1 menu to list games that have been played, based on the current date, and 1 menu to list games that have not been played. basically if $gamedate>$daynow or $gamedate<=$daynow
i've looked up examples online but none of my attempts have worked. perhaps i need to know how to convert $gamedate to a unix time stamp but everything i try doesn't work. I've tried: strtotime, DateTime::, and using "WHERE" and "between" to create a date range
$gamedate is assigned from a MSSQL db and the field is in date format
my thought was to convert $gamedate to the UNIX timestamp and use that to compare to time(). am i correct in thinking this is an integer so using ">" or "<" would work? i'm open to other ways as well.
<?PHP
$daynow=time()
$sql="Select convert(varchar(5), gamedate, 101) AS d, * WHERE gamedate>=$daynow ORDER BY gamedate ASC"
$stmt=sqlsrv_query($conn, $sql);
while ($row=sqlsvr_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
echo"this game has not yet been played";
}
?>
or
<?PHP
$sql="Select convert(varchar(5), gamedate, 101) AS d, * ORDER BY gamedate ASC"
$stmt=sqlsrv_query($conn, $sql);
while ($row=sqlsvr_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
$gamedate=$row['gamedate'];
$daynow=time();
if ($gamedate>$daynow){
echo"this game has not yet been played";}
elseif ($gamedate<=$daynow){
echo"this game has been played";}
}
?>
everything i find is how to covert a timestamp to a string
thank you