user1235285
user1235285

Reputation: 97

DATETIME2 to UNIX timestamp

Is there a simple function to convert the the datetime2 format to output correctly using PHP?

I'm able to get a correct date, but the time always returns as 00:00:00, despite showing correctly on the database.

I'm using the following to output the date/time;

echo $row['OrderDate']->format('d/m/Y H:i:s');

I have tried various suggested solutions without any success (perhaps they only work on datetime, not datetime2?)

Not sure if this is relevant, but the field is set with a precision of 19 and length of 6 in datetime2 format.

The data appears like so in the SQL;

2020-07-13 09:00:48

Any advice would be greatly appreciated!

Upvotes: 0

Views: 272

Answers (0)

Related Questions