将日期查询发送到数据库

    $date = getdate();
    $query = "UPDATE Members Set Name = '$desiredName', Latest_Update = '$date'  Where ID = '$currentID'";
    if(sqlsrv_query($conn, $query)) {
    echo "Record successfully updated.";
    }

I have this query to update a name of a member and whenever I update the name I want to also update the time of the update. Currently this query does not work with the Latest_Update query but everything else works if I remove that. My question is how do I update a datetimeoffset using this query? As at the moment, it does not send the query.

Rather than create the datetime in php, use the built in function SYSDATETIMEOFFSET()

$query = "UPDATE Members Set Name = '$desiredName', Latest_Update = SYSDATETIMEOFFSET() Where ID = '$currentID'";