php上月下月时间获取
来源:互联网 发布:冰川网络珍宝阁 编辑:程序博客网 时间:2024/06/11 19:43
这个在后台做统计查询的时候用的到,这次是财务妹子让我加的,其实也就是利用php自带的函数就能实现了,感觉不错:
if($pre_month && $pre_month == 1 && $start_date && $end_date ){ $timestamp=strtotime($start_date); $start_date=date('Y-m-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)-1).'-01')); $end_date=date('Y-m-d',strtotime("$start_date +1 month -1 day")); }
查询下个月时间:
if($next_month && $next_month == 1 && $start_date && $end_date ){ $time_arr = $this->getNextMonthDays($start_date); $start_date=$time_arr[0]; $end_date=$time_arr[1]; }private function getNextMonthDays($date){ $timestamp=strtotime($date); $arr=getdate($timestamp); if($arr['mon'] == 12){ $year=$arr['year'] +1; $month=$arr['mon'] -11; $firstday=$year.'-0'.$month.'-01'; $lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day")); }else{ $firstday=date('Y-m-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+1).'-01')); $lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day")); } return array($firstday,$lastday);}
复制进去直接就能用,这样感觉果然爽多了。
阅读全文
0 0
- php上月下月时间获取
- Shell获取时间,日期,上月,当月,下月
- Perl 获取上月下月和最大天数
- php获取下月1月1号的时间
- Linux:shell完美获取上月,本月,下月年月
- ASP获取上月本月下月的第一天和最后一天
- php获取本日,昨日,本周,本月,上月,本年时间计算
- php 获取时间,时间戳(上周,上月,上半年,上一年,自定义时间),strtotime(),date()
- PHP 获取 今日 本月 上月
- PHP 获取 今日 本月 上月
- php 获取日期 上周 上月
- MySQL日期获取:本月第一天、本月最后一天、上月第一天、上月最后一天、下月第一天、下月最后一天.....
- C# 获取今天,昨天,上周,下周,上月,下月等等一些日期格式 (转)
- C# 获取今天,昨天,上周,下周,上月,下月等等一些日期格式
- C# 获取今天,昨天,上周,下周,上月,下月等等一些日期格式
- C# 获取今天,昨天,上周,下周,上月,下月等等一些日期格式
- PHP获取上周、本周、上月、本月、本季度、上季度时间方法大全
- PHP获取上周、本周、上月、本月、本季度、上季度时间方法大全
- 软件架构图的艺术
- Tensorflow实战学习(十八)【词向量、维基百科语料库训练词向量模型】
- BCC – Dynamic Tracing Tools for Linux Performance Monitoring
- List<String> list = locationManager.getProviders(true); 为null
- 【辨异】inverse, reverse, converse
- php上月下月时间获取
- Java8中流的性能
- ASCii GBk UTF-8等
- linux中断处理过程
- java类中方法中的参数过多如何处理
- LeetCode 149. Max Points on a Line
- Android 自定义属性,系统控件扩展
- Celery-4.1 用户指南: Workers Guide
- 【笔记】错排