date from datetime sql php code example
Example 1: php mysql datetime
date("Y-m-d H:i:s")
Example 2: php datetime
/**
* Its always best to use a datetime object
*/
$dateTime = new \DateTime();
/**
* You can get the string by using format
*/
$dateTime->format('Y-m-d H:i:s');
Example 3: datetime php
$dateTime = new \DateTime();
$dateTime->format('Y-m-d H:i:s');