[mysql] Get only the date in timestamp in mysql

On my database under the t_stamp columns I have the date for example

2013-11-26 01:24:34

From that same column I only want to get the date

2013-11-26

How can i do this? Thank You!

This question is related to mysql date

The answer is


You can convert that time in Unix timestamp by using

select UNIX_TIMESTAMP('2013-11-26 01:24:34')

then convert it in the readable format in whatever format you need

select from_unixtime(UNIX_TIMESTAMP('2013-11-26 01:24:34'),"%Y-%m-%d");

For in detail you can visit link


$date= new DateTime($row['your_date']) ;  
echo $date->format('Y-m-d');