Convert mssql datetime object to PHP string

后端 未结 9 796
春和景丽
春和景丽 2021-02-05 12:41

I\'m grabbing some information from a database and the record is in an MSSQL DateTime format, when I return it, it shows in my array as follows:

[arrayItem] =>         


        
9条回答
  •  眼角桃花
    2021-02-05 13:25

    If you want to show data in PHP page you just copy and paste in code :

    $serverName = "your_sqlserver";
    $username = "your_username";
    $password = "your_password";
    $database = "your_database";
    $connectionInfo = array( "UID"=>$username, "PWD"=>$password, "Database"=>$database, "ReturnDatesAsStrings"=>true);
    $connection = sqlsrv_connect($serverName, $connectionInfo);
    
    $result = sqlsrv_query( $connection,"SELECT  * from table'");
    $msrow = sqlsrv_fetch_array($result);
    
    print_r($msrow['column_name']);
    

提交回复
热议问题