douju3911 2013-06-16 16:07
浏览 27
已采纳

显示月/日/年 - 不起作用

It is such that I must have set day and month and year, but this is how I have problems with it here:

how the problem looks like now. (The problem is that there is going to be "array ...." before the day and date, and year.) "ArrayTirsdag 11 Jun 2013"

Would like this: "Tirsdag 11 Jun 2013"

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>";
  • 写回答

2条回答 默认 最新

  • doureng6738 2013-06-16 16:26
    关注

    Your problem is you have a . when you need a ; so instead of echoing <td> you're trying to echo all of your logic. So change the first line to echo "<td>"; and you're set. You might as well save the opening <td> for the end too like this:

    // 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条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了