1--TEST-- 2PDO_DBLIB: DATETIME2 column data 3--EXTENSIONS-- 4pdo_dblib 5--SKIPIF-- 6<?php 7require __DIR__ . '/config.inc'; 8if (in_array($db->getAttribute(PDO::DBLIB_ATTR_TDS_VERSION), ['4.2', '4.6', '5.0', '6.0', '7.0', '7.1', '7.2'])) die('skip feature unsupported by this TDS version'); 9?> 10--FILE-- 11<?php 12require __DIR__ . '/config.inc'; 13 14$sql = "SELECT convert(datetime2, '10231017 10:22:44.1355318') AS [d]"; 15 16var_dump($db->getAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT)); 17 18$stmt = $db->query($sql); 19var_dump($stmt->fetch(PDO::FETCH_ASSOC)); 20 21$db->setAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT, 1); 22var_dump($db->getAttribute(PDO::DBLIB_ATTR_DATETIME_CONVERT)); 23$stmt = $db->query($sql); 24var_dump($stmt->fetch(PDO::FETCH_ASSOC)); 25 26?> 27--EXPECT-- 28bool(false) 29array(1) { 30 ["d"]=> 31 string(19) "1023-10-17 10:22:44" 32} 33bool(true) 34array(1) { 35 ["d"]=> 36 string(30) "Oct 17 1023 10:22:44:1355318AM" 37} 38