问题
based on this code :
$tarikh = mysql_real_escape_string($_POST['tarikh']);
$tarikh = date('Y-m-d', strtotime($_POST['tarikh']));
can someone show me to convert the format from Y-m-d to d-m-Y format ? thanks
回答1:
try this
$tarikh = mysql_real_escape_string($_POST['tarikh']);
$myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh);
$newDateString = $myDateTime->format('d-m-Y');
来源:https://stackoverflow.com/questions/25697016/change-date-format-from-y-m-d-to-d-m-y