Why is dbTimeStamp() adding a comma?

60 views Asked by At

I have the following code:

$NOW = $db->dbTimeStamp(time());

And using that in a query it is producing a timestamp like this:

2021-01-13, 08:17:06PM

However, that comma seems to be causing the query to fail in SQL Server 2005. Is there a way to get it to not include that comma.

I'm running PHP 7.4 on Debian 10 connecting to SQL Server 2005 with the odbc driver.

EDIT: Here's how I'm using it in a query:

$sql = "UPDATE podocument SET deleted = '1', lastseen = {$NOW} WHERE (purchaseOrderId = '{$purchaseOrderId}')";
$res = $db->execute($sql);
1

There are 1 answers

0
Martin Cairney On

Darrell

Rather than using the time() function, can you instead use the date() function as described here and using a format string of "Ymd H:i:s"

Using this format string is always correctly recognised in SQL Server.