if ($conn) {
echo "connected" . "<br/>";
$datetimenow = current_time("d.m.Y H:i");
echo $datetimenow; // 30.05.2020 14:13
$myquery = "
DECLARE @T DATETIME = '$datetimenow'
SELECT @T
SELECT CONVERT( VARCHAR, @T, 104 ) + ' ' + LEFT( CONVERT( VARCHAR, @T, 8 ), 5 )
SELECT FORMAT( @T, 'dd.MM.yyyy HH:mm' )
SELECT * FROM dbo.GorElectroTrans WHERE GPS_datetime=@T
";
if (($result = sqlsrv_query($conn, $myquery)) !== false) {
while ($obj = sqlsrv_fetch_object($result)) {
echo $obj->Longitude . '<br />';
}
}
} else {
die(print_r(sqlsrv_errors(), true));
}