Reputation: 2275
Maybe is a dumb question, but I can't find the proper function:
I have a string date like 04/05/2012
How I can pass to this format: 2012-04-05 20:18:11
to insert in mySQL?
Upvotes: 0
Views: 173
Reputation: 80639
Time can not be 'made' on its own. If you're however inserting the current date-time setting, then the following code will be used:
$dt = date( "Y-m-d H:i:s", time() );
You may use dleiftah
's statement, but the time in that case will always be 00:00:00
Upvotes: 1
Reputation: 55952
$dateTime = new DateTime($your_time_string);
echo $dateTime->format("Y-m-d H:i:s");
Upvotes: 1
Reputation: 3273
Combination of date and strtotime ...
$my_date = date('Y-m-d H:i:s',strtotime('04/05/2012'));
Upvotes: 3