jdoe jdoe - 5 months ago 137
PHP Question

how to convert date format in a textarea php mysql

I want to change the date format in a text area,

<textarea tabindex="0"
class="input_lkl "
name=""><?php echo $class['new']['ord_added_usr']; ?></textarea>

and it show me the date format like this

[120] Added by [admin] on [2016-05-18]

and I want to change the format into Y-m-d to d-m-Y

[120] Added by [admin] on [18-05-2016]


Assuming $class['new']['ord_added_usr'] holds [120] Added by [admin] on [2016-05-18]

You can use preg_replace_callback

echo preg_replace_callback("/(\d{4}-\d{2}-\d{2})/", function($matches){
    return date("d-m-Y",strtotime($matches[0]));


[120] Added by [admin] on [18-05-2016]