im trying to change the date format when im displa

2019-03-07 02:06发布

This question already has an answer here:

In the database, date format is Y-m-d, im trying to display my result with this format d-m-Y.

This is my code:

<input name="personal_ic_from" type="text" class="tcal" id="personal_ic_from" value="<?php echo $personal_ic_from ?>" readonly="readonly"/>

1条回答
劫难
2楼-- · 2019-03-07 02:38

Follow the procedural style in php

<?php
$databaseDate = '2013-09-29 01:02:03';
$date = date_create($databaseDate);
echo date_format($date, 'd-m-y');
?>

You can also try strtotime()

<?php
$queryResultDate = mysqli_query("SELECT column_name FROM table_name"); //selecting the  date column
 $date = date("d-m-y" , strtotime($queryResultDate));
echo $date;
?>
查看更多
登录 后发表回答