duanjie9630 2015-06-23 11:54
浏览 145
已采纳

下个月使用mktime()获取

I'm trying to get the next month using PHP mktime() function.

I am looking to get a result like 07/2015 but instead it is giving me 01/2015.

Here is the code I am using:

$next_month = strftime('%d/%Y', strtotime('+1 month', mktime(0,0,0,$month,1,$year)));

The value of $month is 06.

The value of $year is 2015.

  • 写回答

2条回答 默认 最新

  • douzhuan0309 2015-06-23 12:00
    关注

    If you insist on using your version, then it should be %m instead of %d, i.e.:

    $year = 2015;
    $month = 6;
    echo strftime('%m/%Y', strtotime('+1 month', mktime(0,0,0,$month,1,$year)));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试