drhwb470572 2013-06-16 23:48
浏览 16

PHP中的MySQL日期格式

How can i show this as a DAY rather than full date

echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $row['date'] . "</td>";

i already have

date_default_timezone_set('Europe/London');

i have a similar question already asked but mistakenly put it as MYSQLi but i need MYSQL PHP support on this

the date and time is correctly set for the timezone but on viewing the PHP i want to view it as a Day

  • 写回答

3条回答 默认 最新

  • doukanhua0752 2013-06-16 23:51
    关注

    Use the date() function in PHP to change the date format...

    date('l',strtotime($row['date']));
    

    So your code changes to this...

    echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . date('l',strtotime($row['date'])) . "</td>";
    

    Info on date()

    Date can display in many different ways...

    date('Y-m-d');  //2013-06-17 format
    date('z'); //day of the year
    date('l'); //textual day of week
    

    See here for details...

    http://php.net/manual/en/function.date.php

    UPDATE

    You are having trouble with the format, so you can fix it like this...

    $date = explode(" ",$row['date']);
    $date2 = explode("/",$date[0]);
    $displayDay = date('l',strtotime($date2[2]."-".$date2[1]."-".$date2[0]));
    

    Then just echo that line with

    echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $displayDay  . "</td>";
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度