News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Swan's Blog:
SQL Server Driver for PHP Connection Options ReturnDatesAsStrings
February 09, 2011 @ 08:45:28

Brian Swan has a new post to his blog today looking at one of the connection options for the SQL Server driver in PHP - the "ReturnDatesAsStrings" setting that can make handling date and time information simpler for PHP.

This is short post to address a frustration I've seen mentioned on Twitter and in forums a lot: By default, the SQL Server Driver for PHP returns datetime columns as PHP DateTime objects, not strings. This can be especially frustrating if you are not aware of the ReturnDatesAsStrings connection option. By simply setting this option to 1 (or true) when you connect to the server, datetime columns will be returned as strings.

He includes some sample code showing how to use the setting (as a part of the settings array passed in to sqlsrv_connect) and the resulting array key from the fetched results on his sample table. This just gives you one more option for handling dates in your SQL Server-based application, especially if you don't need the full DateTIme object's functionality.

0 comments voice your opinion now!
sqlserver driver connection option return date string datetime


blog comments powered by Disqus

Similar Posts

Ilia Alshanetsky's Blog: PHP 5.2.0 RC1 Released!

Sameer Borate: Period: Time range API for php

PHPBuilder.com: An introduction to PEAR's Validate package

Mike Bernat's Blog: CakePHP - Changing the Default Value of a Date-Time Input

Ariz Jacinto's Blog: Compiling PHP with MSSQL Server's Native ODBC Driver for Linux as a PDO Driver


Community Events





Don't see your event here?
Let us know!


symfony community composer tool security interview language release podcast artisanfiles conference list series framework version opinion introduction library voicesoftheelephpant laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework