title: Saving datetime to MSSQL database from PHP - throws error
body: <p>I have PHP web app, which has been deployed to several computers without problem. Just in this one case, I have problem when saving datetime to MSSQL database. The message says:</p>
  
  <blockquote>
    <p>SQLSTATE[22007]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server] Conversion of a varchar data type to a datetime data type resulted in an out-of-range value. </p>
  </blockquote>
  
  <p>I've been always saving datetime format from php to database as <code>date('Y-m-d H:i:s')</code> (but I need to also save another dates, not just current date). When I make the insert (which throwed error from php) directly through SQL Management studio, it works. Just when it is saved using php, it throws this error. </p>
  
  <p>Now I've edited saving date from php as <code>date('Y-m-d\TH:i:s')</code> which works on this particular instance, but I'd rather found a way how to </p>
  
  <ol>
  <li>detect the format which will work when saving datetime from php
  to database  </li>
  <li>or change the format (I dont know if this is PHP
  configuration, driver or else).</li>
  </ol>
  
  <p>I've been searching for some way but all I found was how to do conversion, etc.  </p>