drzfnr0275 2013-10-18 15:49
浏览 199
已采纳

用PHP格式化工作日,日月,年格式的日期? [关闭]

How do I format a date in the format such as weekday, day month, year for example Friday, 18th October 2013? I have tried using strotime() and the echoing using date() function but can't achieve this format because weekday is not being returned properly.

  • 写回答

2条回答 默认 最新

  • douqiang4501 2013-10-18 15:53
    关注

    This works correctly:

    // Use string to time to get the date as a unix timestamp
    $myTime = strtotime("Friday, 18th  October 2013");
    
    // Use that timestamp to reform it into a date, in which ever format you want orrding to the date() documentation.
    $newTime = date('l, jS F Y', $myTime);
    
    // Show the date in the format
    echo $newTime;
    

    See it working here: http://www.tehplayground.com/#i9U7grxCr

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析