Possible Duplicate:
How to convert DateTime to VarChar
Example
How do you convert a SQL datetime (for example 08/14/2012 1:05:18 PM
) to the mysql way ( that is Y-m-d H:i:s )?
Possible Duplicate:
How to convert DateTime to VarChar
Example
How do you convert a SQL datetime (for example 08/14/2012 1:05:18 PM
) to the mysql way ( that is Y-m-d H:i:s )?
Depends on where you are wanting to convert it.
To convert in your SQL directly:
convert(varchar(23), getdate(), 121)
PHP using the date and strtotime functions:
date("Y-m-d H:i:s ", strtotime("08/14/2012 1:05:18 PM"));
Change the format of the date in PHP like so:
<?
$date = date("Y-m-d H:i:s ", strtotime("08/14/2012 1:05:18 PM"));
echo $date;
?>
$var = "08/14/2012 1:05:18 PM";
echo date('Y-m-d H:i:s', strtotime($var));