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 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件