Reputation: 5764
I am hosting a php application on Windows server 2008 and using SQL Server 2008. I am having issues with inserting dd/mm/yyyy date strings in to the database.
How can I manually convert my dd/mm/yyyy string into the MS SQL Server date format YYYY-MM-DD HH:MM:SS within PHP code?
Upvotes: 0
Views: 6742
Reputation: 9968
// e.g. '12/12/2040' will not work
$date = strtotime('12/12/2035');
if($date !== false)
{
$date = date('Y-m-d h:i:s' , $date);
}
else
{
$date = 'can\'t convert';
}
echo $date;
Upvotes: 0
Reputation: 2045
$date = strtotime('11/01/2012');
$new_date = date('Y-m-d H:i:s', $date);
Upvotes: 2
Reputation: 86366
You can use the date
and strtotime
functions
$date=date('Y-m-d h:i:s', strtotime($date_in_ddmmyyyy));
Upvotes: 3