Convert a mysql date (datetime) into a better date format using php

前端 未结 3 1588
一向
一向 2021-01-19 03:15

I some php code which gets info from a mysql database. The problem is that the date is coming out in the format : \"2010-02-03 22:21:26\"

Does anyone kn

相关标签:
3条回答
  • 2021-01-19 03:33

    See strtotime() and date()

    e.g., 2010-02-03 22:21:26 to 3rd February 2010 at 22:21:

    $DateTimeStr = '2010-02-03 22:21:26';
    echo date('jS F Y \a\t G:i', strtotime($DateTimeStr));
    
    0 讨论(0)
  • 2021-01-19 03:45

    Or use the datetime-class.

    0 讨论(0)
  • 2021-01-19 03:55

    date() function will assist you in this.

    Something like

    $date = date('j F, Y h:i:s', strtotime($date_value));
    print $date;
    

    Format options:

    http://www.php.net/manual/en/function.date.php

    0 讨论(0)
提交回复
热议问题