Closed matak closed 8 years ago
AFAIK, default date format depends on session language. You can change the session language or maybe set the DATEFORMAT.
This is issue of MsSQL, not Dibi by my opinion. To get DateTime object in PHP from DIBI, you should use CONVERT in QUERY and then setType method of Dibi (or asDateTime on Dibi\Row)
$query->setType('column', \Dibi::DATETIME)->fetch();
$row->asDateTime('column')
See this https://api.dibiphp.com/3.0.1/source-Dibi.Row.php.html#31-47 https://api.dibiphp.com/3.0.1/source-Dibi.Result.php.html#537-547
@dg close please, this is not bug
Probably condition can be improved to accept this format.
@dg Thanks 👍
if you select datetime column mssql returns
something like this
Jun 17 2015 12:00:00:000AM
but normalize function will not create DateTime object bcs
https://github.com/dg/dibi/blob/master/dibi/libs/DibiResult.php#L508
this is not true
(int) $value !== 0
if you want to get from mssql date format like this 2015-06-17 00:00:00
you need to use this
CONVERT(VARCHAR(19), d.Datum, 120) as Datum,
in your query, but this will be detected like string not datetime so again DateTime object will not be created