Get only the date in timestamp in mysql

前端 未结 3 473
悲哀的现实
悲哀的现实 2020-12-28 13:00

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<

相关标签:
3条回答
  • 2020-12-28 13:22

    You can use date(t_stamp) to get only the date part from a timestamp.

    You can check the date() function in the docs

    DATE(expr)

    Extracts the date part of the date or datetime expression expr.

    mysql> SELECT DATE('2003-12-31 01:02:03'); -> '2003-12-31'

    0 讨论(0)
  • 2020-12-28 13:22

    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

    0 讨论(0)
  • 2020-12-28 13:47
    $date= new DateTime($row['your_date']) ;  
    echo $date->format('Y-m-d');
    
    0 讨论(0)
提交回复
热议问题