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 CreateFile无法获取特殊文件内容
  • ¥35 基于python的有ssl加密传输的socket聊天室
  • ¥15 数码管亮度控制器设计
  • ¥15 kafka客户端跨网段访问,看日志提示连接的还剩内网地址,且访问不通
  • ¥15 关于c语言代码的问题
  • ¥15 c51单片机控制步进电机
  • ¥20 Visual studio无法检测到设备
  • ¥30 vue 页面窗口放大或者缩小元素会变化
  • ¥15 questasim仿真报错
  • ¥15 寻找电脑攻防的导师,有问题请教一下。