sql server - Php MSSQL_connect Date Issue

491

I'm connecting to a mssql server database using my linux cpanel server with php & freeTDS, I can connect and pull all the data i need from the DB but when I pull a date from the database its comes through as a different format,

here is my code

    $db = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer");

    $query = "SELECT * FROM Invoices Where ID = '".$id."'"; 
                     $result = mssql_query($query);

                    $invoice_d = mssql_result($result,$i,'invoice_date');

    echo $invoice_d;

But this returns as "Jun 16 2017 12:00:00:AM"

In the mssql databse it is saved in the format 2017-06-16, so i'm not sure why its being or where its being converted.

I have tried converting this unsing date_format and strtotime but none will work, i have also edited the local.conf file in the freetds folder but to no avail.

Thanks

People are also looking for solutions to the problem: Insert inner arrays in JSON-encoded array to csv-file with php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.