format("yourFormatSpecifier"); Now you can implement the above syntax in PHP code to extract the unique date from the datetime field . The PHP code is as follows-$MySQLDataBaseDateTime="2018-02-1313:10:15""/> format("yourFormatSpecifier"); Now you can implement the above syntax in PHP code to extract the unique date from the datetime field . The PHP code is as follows-$MySQLDataBaseDateTime="2018-02-1313:10:15"">
Home >Database >Mysql Tutorial >Extract only date from datetime field in MySQL and assign it to PHP variable?
If you want to extract a unique date from a datetime field, you need to use the DateTime class. The syntax is as follows -
DateTime::createFromFormat("Y-m-d H:i:s",yourDateTimeValue)->format("yourFormatSpecifier");
Now you can implement the above syntax in your PHP code to extract unique dates from datetime fields. The PHP code is as follows -
$MySQLDataBaseDateTime = "2018-02-13 13:10:15"; echo DateTime::createFromFormat("Y-m-d H:i:s",$MySQLDataBaseDateTime)->format("d/m/Y");
This is the screenshot of the PHP code -
13/02/2018
The above is the detailed content of Extract only date from datetime field in MySQL and assign it to PHP variable?. For more information, please follow other related articles on the PHP Chinese website!