PHP - Insert date time object in the type of DateTime column in database
Posted: 30 Jan 2015, 08:34
I want to insert a DateTime object in database (created in PHP) where the column type is DateTime. How can I do?
I am using this code:
I am using this code:
Code: Select all
$cdate = new DateTime('now');
$cd = $cdate->format('d/m/Y h:i:sa');
$udate = new DateTime('72 hours');
$ud = $udate->format('d/m/Y h:i:sa');
$sql = "INSERT INTO table (name, cd, ud) VALUES ('some_name', '$cd', '$ud')";