我必须设定日,月,年,但这就是我在这里遇到的问题:
现在问题如何。 (问题是在日期,日期和年份之前会有“数组......”。) “ArrayTirsdag 2013年6月11日”
想要这样: “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>";
答案 0 :(得分: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>";
答案 1 :(得分: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>";