我想更改日期格式,如
$date ="21 dec '15";
到
$date ="21-12-2015";
如何在php中实现。
答案 0 :(得分:6)
$date = DateTime::createFromFormat('!m', $result['month']);
echo $date->format('F');
F stands for "month name",
答案 1 :(得分:0)
使用此
$date = "21 dec '2015"; #your date
$replaced_date = str_replace("'","",$date);
$new = date_create($replaced_date);
$new_date = date_format($new, "d-m-Y"); # restructer the date
echo $new_date ;
答案 2 :(得分:0)
$date = new DateTime(str_replace("'", '20', "21 dec '15"));
var_dump($date->format('d-m-Y'));