For instance:
$sql = "SELECT * FROM db";
$query = sqlsrv_query($conn, $sql);
while($row = sqlsrv_fetch_array($query)){
echo "$row[date_column]";
}
will crash
Most of the answers I've found are assuming you want to order your query by a datetime, but I just want to turn the datetime object into a string after I have all the rows.
I don't really understand how to use the php date() function, I've tried:
echo date("m/d/Y",$row[date_column]); //prints nothing
$string=$row["date_column"]->format('Y-m-d H:i:s')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With