Convert DateTime class to string
date, php, sql, sql-server, string
Solution
in php you can simply use `date_format($date, 'Y-m-d')`
<?php
$date = date_create('2013-11-23 05:06:07');
echo date_format($date, 'Y-m-d');
?>
returns 2013-11-23
Problem
Currently I am retrieving a date from mssql with the data type of small date time. The data is : `2013-03-12 00:00:00` I want to store it in a variable and then display on a text box. And the format I want to display is just `2013-03-12` on the text box. The message I get is: catchable fatal error : Object of class DateTime could not be converted to string. Any idea?