• 注册
  • 代码教程 代码教程 关注:6 内容:36

    php日期相加,增加天数、月数等,已有时间增加天数等

  • 查看作者
  • 打赏作者
  • 9 渡劫 后期

    当前时间增加一天:

    echo date('Y-m-d',strtotime("+1 day"))

    当前时间增加一月:

    echo date('Y-m-d',strtotime("+1 month"))

    当前时间增加一年: 

    echo date('Y-m-d',strtotime("+1 year"))

    当前时间增加一秒:

    echo date('Y-m-d',strtotime("+1 seconds"))

    上个月的天数

    echo "上个月份天数:".date('t',strtotime('-1 month'));//上个月的天数

    当前月份天数

    echo "<br>当前月份天数:".date('t');//当前月份天数

    已有时间增加一天: 

    $d='2020-11-22';//已有的时间
    echo date('Y-m-d',strtotime("{$d} +1 day"));//在已有的时间上增加1天

    更多的有

    echo   strtotime( 'yesterday ') 
    echo   date( "Ymd ",strtotime( 'last   week '));

    请登录之后再进行评论

    登录
  • 任务
  • 偏好设置
  • 到底部
  • 帖子间隔 侧栏位置: