The result of the below code gives: Januar 9, 2014
How is it possible to make it to: 9. Januar 2014
Thanks in advance.
<?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;
}
?>