JoHa
JoHa

Reputation: 2039

PHP with SQL Server: strtotime() with SQL Server DATETIME column

So I have SQL Server datetime field, and in PHP I want to use this as a UNIX TIMESTAMP, because I want to use it with strtotime, in order to add 14 days into it. Eg. If it is stored in the SQL Server database as: 2010-07-27 13:12:22.040 I want to add 14 days into it to become 2010-08-10 13:12:22.040

How would I do that using PHP with SQL Server datetime field? strtotime() command takes only UNIX timestamp.

If can't be done in PHP with SQL Server , how would I do it in SQL Server and then select it with the values I am selecting?

Upvotes: 0

Views: 2751

Answers (2)

CrayonViolent
CrayonViolent

Reputation: 32532

strtotime() takes a string date format, but anyway, you can also look into mktime().

Upvotes: 0

OMG Ponies
OMG Ponies

Reputation: 332581

how would I do it in SQL Server and then select it with the values I am selecting?

Use DATEADD:

SELECT DATEADD(dd, 14, date_column)

...to add 14 days to the column value.

Upvotes: 1

Related Questions