当前月

<?php
$thismonth = date('m');
$thisyear = date('Y');
$startDay = $thisyear . '-' . $thismonth . '-1';
$endDay = $thisyear . '-' . $thismonth . '-' . date('t', strtotime($startDay));
$b_time = strtotime($startDay);
$e_time = strtotime($endDay);

上一月

<?php
$thismonth = date('m');
$thisyear = date('Y');
if ($thismonth == 1) {
$lastmonth = 12;
$lastyear = $thisyear - 1;
} else {
$lastmonth = $thismonth - 1;
$lastyear = $thisyear;
}
$lastStartDay = $lastyear . '-' . $lastmonth . '-1';
$lastEndDay = $lastyear . '-' . $lastmonth . '-' . date('t', strtotime($lastStartDay));
$b_time = strtotime($lastStartDay);
$e_time = strtotime($lastEndDay);

这里对关键的就是date函数中的t,它是用来获取当前月所含天数的,28天,29天,30天,31天。含有多少天,月底就是多少号。

最新文章

  1. Rabin-Karp指纹字符串查找算法
  2. 在VM虚拟机上安装Microsoft Dynamics CRM 2016 步骤图解及安装注意事项
  3. 工作框架各种使用整理---使用Cache
  4. Unity手游之路&lt;八&gt;自动寻路Navmesh之入门
  5. Glide 下载Gif文件
  6. java和Javascript的区别
  7. 机器学习中的范数规则化之(一)L0、L1与L2范数(转)
  8. HDU 3333 Turing Tree (树状数组)
  9. 自己实现的简单MVC框架(类似Struts2+Spring)
  10. Asp.net Web.Config - 配置元素customErrors
  11. 8、Spring+Struts2+MyBaits(Spring注解+jdbc属性文件+log4j属性文件)
  12. Java_中快速获取系统时间
  13. Python:main函数
  14. c# 向数据库插数据超过1000条
  15. NSAssert和NSParameterAssert
  16. 16、JDBC-DBUtils封装
  17. canvas里设置width和css里设置width和js里设置width的区别
  18. 加快Gradle的构建过程
  19. 025 如何利用github绑定自己的域名
  20. ASP.NET实现头像剪切保存

热门文章

  1. 布置weblogic10 64位系统
  2. Ubuntu16.04 Kdevelop汉化及配置
  3. UIElement.IsMouseCaptured属性的应用
  4. Educational Codeforces Round 23E
  5. uva 1511 最小生成树
  6. CountDownLatch闭锁
  7. 【牛客练习赛12-B】迷宫(BFS)
  8. 下载并安装Prism5.0库 Download and Setup Prism Library 5.0 for WPF(英汉对照版)
  9. LeetCode OJ:First Bad Version(首个坏版本)
  10. TCP与UDP(实时通讯)