1--TEST-- 2PDO_DBLIB: PDO::DBLIB_ATTR_DATETIME_CONVERT 3--EXTENSIONS-- 4pdo_dblib 5--SKIPIF-- 6<?php 7require __DIR__ . '/config.inc'; 8?> 9--FILE-- 10<?php 11require __DIR__ . '/config.inc'; 12 13$sql = "SELECT convert(datetime, '20171027 10:22:44.135') 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// assume default date format: %b %e %Y %I:%M:%S:%z%p 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) "2017-10-27 10:22:44" 32} 33bool(true) 34array(1) { 35 ["d"]=> 36 string(26) "Oct 27 2017 10:22:44:137AM" 37} 38