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

报告相同问题?