Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separating date and time from datetime format mysql

I have an event page that displays events from database. In my database, I have a column with datetime format. is there a way to only get the date or time separate from each other in a select to be displayed in PHP ?

Note : I am looking for anything default/core PHP function for this issue.

like image 251
Kamesh Jungi Avatar asked Sep 19 '25 14:09

Kamesh Jungi


1 Answers

Use this query , you will get your desired output :

$sql = "SELECT DATE(datecolumn) as mydate, TIME(datecolumn) as mytime FROM `tablename`";
like image 161
Debarth Avatar answered Sep 22 '25 04:09

Debarth