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