dtotuki47568
dtotuki47568
2014-10-22 05:31

DateTime :: createFromFormat月份名称[关闭]

已采纳

I'm using DateTime::createFromFormat in PHP like this:

$month = DateTime::createFromFormat("Y-m-d", '2014-08-01');

But echo $month is showing up as 08. How can I display it as a 3 letter name, i.e.: Aug?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • douzhi7451 douzhi7451 7年前

    Use capital M instead of m .

      $getMonth = DateTime::createFromFormat("Y-m-d", '2014-08-01');
    

    If you already have the date variable created then you can use directly the below code

     $month = $getMonth->format('M');
    
    点赞 评论 复制链接分享

相关推荐