0

就是这样,我必须设置日期、月份和年份,但这就是我在这里遇到问题的原因:

现在的问题如何。(问题是在日期和年份之前会有“array ....”。)“ArrayTirsdag 11 Jun 2013”

想要这样:“Tirsdag 2013 年 6 月 11 日”

echo "<td>" . 
                $days = array("Mandag","Tirsdag", "Onsdag","Torsdag","Fredag","Lørdag","Søndag");
                $months = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
                $timestamp = strtotime($c->pubDate);
                $dayInWeek = $days[date('N', $timestamp)-1];
                $month = $months[date('n', $timestamp)-1];
                $dayInMonth = date('d', $timestamp);
                $year = date('Y', $timestamp);
                echo $dayInWeek . ' ' .$dayInMonth. ' '.$month.' '.$year
                . "</td>";
4

2 回答 2

0

你的问题是你有一个.当你需要的;时候,而不是回应<td>你试图回应你所有的逻辑。因此,将第一行更改为即可echo "<td>";。您也可以像这样保存<td>结尾的开头:

// date logic
$days       = array("Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag");
$months     = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
$timestamp  = strtotime($c->pubDate);
$dayInWeek  = $days[date('N', $timestamp)-1];
$month      = $months[date('n', $timestamp)-1];
$dayInMonth = date('d', $timestamp);
$year       = date('Y', $timestamp);

echo "<td>$dayInWeek $dayInMonth $month $year</td>";
于 2013-06-16T16:26:50.823 回答
0

你有 。而不是第一次回显时的逗号。

echo "<td>"; 
                $days = array(1=>"Mandag","Tirsdag", "Onsdag","Torsdag","Fredag","Lørdag","Søndag");
                $months = array(1=>"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
                $timestamp = strtotime($c->pubDate);
                $dayInWeek = $days[date('N', $timestamp)];
                $month = $months[date('n', $timestamp)];
                $dayInMonth = date('d', $timestamp);
                $year = date('Y', $timestamp);
                echo $dayInWeek . ' ' .$dayInMonth. ' '.$month.' '.$year
              . "</td>";
于 2013-06-16T16:27:06.543 回答