首页 > 编程语言 >根据当天日期,获取未来多个月份的今天(包含2月份日期不足处理逻辑)----PHP

根据当天日期,获取未来多个月份的今天(包含2月份日期不足处理逻辑)----PHP

时间:2023-09-01 11:47:18浏览次数:35  
标签:strtotime end month current next ---- 日期 date PHP

public function next_month_today($date){
//获取今天是一个月中的第多少天
$current_month_t = date("t", strtotime($date));
$current_month_d= date("d", strtotime($date));
$current_month_m= date("m", strtotime($date));

//获取下个月最后一天及下个月的总天数
$next_month_end= $this->getNextMonthEndDate($date);
$next_month_t = date("t", strtotime($next_month_end));

$returnDate='';
if($current_month_d==$current_month_t){//月末
//获取下个月的月末
$returnDate=$next_month_end;
}else{//非月末
//获取下个月的今天
if($current_month_d>$next_month_t){ //如 01-30,二月没有今天,直接返回2月最后一天
$returnDate=$next_month_end;
}else{
$returnDate=date("Y-m", strtotime($next_month_end))."-".$current_month_d;
}
}
return $returnDate;
}
public function getNextMonthEndDate($date){
$firstday = date('Y-m-01', strtotime($date));
$lastday = date('Y-m-d', strtotime("$firstday +2 month -1 day"));
return $lastday;
}

标签:strtotime,end,month,current,next,----,日期,date,PHP
From: https://www.cnblogs.com/bastblogs/p/17671437.html

相关文章

  • 用 ChatGPT 做一个 Chrome 扩展 | 京东云技术团队
    用ChatGPT做了个ChromeExtension最近科技圈儿最火的话题莫过于ChatGPT了。最近又发布了GPT-4,发布会上的Demo着实吸睛。笔记本上手画个网页原型,直接生成网页。网友直呼:前端失业了!但我觉着啊,真就外行看热闹,内行看笑话。虽然ChatGPT很强大,但没有经过针对某个领域自定义化过的模......
  • ogg 的抽取进程 2015-06-17 05:51:08 ERROR OGG-02077
    报错信息如下HowtoresolveExtractAbendingWithOGG-02077Error(DocID2037420.1)这种情况是把抽取进程注册到数据库中了,你又强制启动相同的抽取进程,就会与数据库中注册的进程冲突,你可以执行下边语句删除数据库中抽取进程Stepstoclearthespecificextractcomponen......
  • 解决方案 | tk.entry数字验证(输入框如何保证只能输入数字)
      fromtkinterimport*root=Tk()#创建文本框entry=Entry(root)entry.pack()#设置文本框只能输入数字entry.config(validate="key",validatecommand=(root.register(lambdaP:P.isdigit()orP==""),"%P",),)root.mainlo......
  • docker查看镜像、运行容器、端口映射
    查看镜像dockerimagesdockerimagels查看容器dockerps查看所有容器dockerps-a运行镜像dockerrun[options]image-d后台-i交互式shell-t为容器重新分配伪输入终端,和-i同时使用端口映射-p[hostip:]hostport:containerport......
  • 可视化流程设计平台有啥优势?
    在流程化办公发展趋势逐渐明朗的今天,运用什么样的平台可以帮助广大用户朋友实现这一目标?可视化流程设计平台是轻量级、更灵活、易操作、效率高的平台,可以快速定制客户专属的框架平台,为每一位客户朋友做好数据管理,实现高效率、高质量的办公。如果需要做好数据管理,需要提高办公协作......
  • Python中while的and和or
    whileAandB:同时满足A和B条件whileAorB:满足A或B任意一条以1768.交替合并字符串官方答案为启发,以前没意识到while还可以用and和or。其实无论用什么,只要看最后的结果是True或FalseclassSolution:defmergeAlternately(self,word1:str,word2:str)->str:......
  • dockerfile
    dockerfileWORKDIR:进入某个文件,等同于cdEXPUSE:暴露XX端口CDM:启动某个程序,在一个docekrfile里面只生效一次ENTRYPOING:也可以启动某个程序ADD:将一个文件直接复制到容器指定的目录中(ADDnginx-1.24.0.tar.gz./),将压缩之后的文件解压缩到指定的目录并删除压缩文件(仅支持一层目......
  • 【CF1503A】Balance the Bits(构造)
    题目大意:#include<bits/stdc++.h>usingnamespacestd;typedeflonglongll;lln;chars[200000+10];chara[200000+10],b[200000+10];intmain(){ ios::sync_with_stdio(0); cin.tie(0); intT; cin>>T; while(T--){ cin>>n>>(s+......
  • armbian ZeroTier在线安装
    1、在线安装curl-shttps://install.zerotier.com|sudobash2.常用操作 zerotier服务状态:#返回信息“200info###########1.10.6ONLINE”zerotier-clistatuszerotier手动启动:sudosystemctlstartzerotier-one.servicezerotier......
  • Vue3 全局 CSS 样式
    在Vue3中设置全局的网页样式  ......