Date format in PHP from SQL server

Asked

Viewed 394 times

1

I am running the following code:

$sql= mssql_query("select getdate()");
$res = mssql_fetch_assoc($sql);

and he’s returning me the following date:

2015-04-10 32767:06

The time is five digits, someone knows why?

ps. I have already amended the directive of php.ini for: mssql.datetimeconvert = Off

  • Have you tried date(’d-M-Y', strtotime($datadobanco)); ?

  • 1

    Yes. but I need to set this in the PHP configuration because there are many querys with this problem.

  • 1

    It’s almost the same problem as that question: Problems to convert data mon dd yyyy hh:mm and uses the same API mssql_*.

  • You need the time?

  • date('Y-m-d H:i:s', strtotime($databanco);

1 answer

2

Change your query to the code below:

SELECT CONVERT(VARCHAR(19), GETDATE(), 120) AS DATA

As a result you’ll have something like:

2015-10-02 13:45:05

Browser other questions tagged

You are not signed in. Login or sign up in order to post.