0
下面的代碼的結果給出:Januar 9 2014PHP轉換日期爲d-M-Y格式
怎麼可能使其向:9 Januar 2014
在此先感謝。
<?php
global $months;
$months = array('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December');
function convert_dates($text)
{
$date_regexp = '/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/';
preg_match_all($date_regexp, $text, $dates);
$dates = $dates[0];
$new_dates = $dates;
for($i=0;$i<count($new_dates);$i++) {
$new_dates[$i] = explode('-', $new_dates[$i]);
$new_dates[$i] = $GLOBALS['months'][abs($new_dates[$i][1])-1] . ' ' . abs($new_dates[$i][2]) . ', ' . $new_dates[$i][0];
}
$text = str_replace($dates, $new_dates, $text);
return $text;
}
?>
它不是我想要的。我想使用上面的代碼,但我必須切換數字(日期)和文本(月)。 – RedHawkDK
這不重複。這是完全不同的。 – Zlatan
用'echo date('j。F Y')來試一試''(altrhought月份的名字是英文的) – Zlatan