Change the date format in phpmyadmin

前端 未结 3 1100
花落未央
花落未央 2021-02-04 16:48

I m trying to change the date format in phpmyadmin. I m unable to change the format I want to change the format to dd-mmm-yyyy. How can I change the date format. Please help me

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-04 17:38

    It's not possible as far as I know. I stand corrected, see @Madhura Jayaratne's answer for how to change the date format using phpMyAdmin. However, if that's not available or you don't have permission, you can use the solution below to reformat it in PHP.

    Let's say your $date_from_sql is set to 2014-03-23.

    $date = date('d-m-Y', strtotime($date_from_sql)); //date format
    

    Now $date equals 23-03-2014


    Optionally you can wrap it in a function to use it throughout your application.

    function fixdate($date) {
        return date('d-m-Y', strtotime($date));
    }
    
    // When parsing data from the database:
    $query = query("SELECT wrongdate FROM something")->result();
    $date = fixdate($query->date);
    

提交回复
热议问题