PHP自带的strtotime()对于31日求上个月有问题,如下:

<?php
$date = "2012-07-31";
$date_unix = strtotime($date);
$lastmonth = strtotime("last month",$date_unix);//或者strtotime("-1 month",$date_unix);
echo date("Y-m-d H:i:s",$lastmonth)."<br />";//输出:2012-07-01 00:00:00
$last_month_end = strtotime(date("Ym"."01000000",$date_unix)) - 1;//上个月的最后一秒
echo date("Y-m-d H:i:s",$last_month_end);//输出:2012-06-30 23:59:59
?>

phpstrtotime()对于31日求上个月有问题的更多相关文章

  1. PHP中的strtotime()对于31日求上个月有问题

    原文出处 <?php $date = "2012-07-31"; $date_unix = strtotime($date); $lastmonth = strtotime( ...

  2. java中求一下2008年5月31日, 往前倒30天是哪天?

    题目9: 2008年5月31日, 往前倒30天是哪天?  import java.util.*; public class Test {     public static void main(Str ...

  3. 2016年12月31日 星期六 --出埃及记 Exodus 21:26

    2016年12月31日 星期六 --出埃及记 Exodus 21:26 "If a man hits a manservant or maidservant in the eye and d ...

  4. 2016年10月31日 星期一 --出埃及记 Exodus 19:16

    2016年10月31日 星期一 --出埃及记 Exodus 19:16 On the morning of the third day there was thunder and lightning, ...

  5. MyOD课堂实践(5月31日)20155318

    MyOD课堂实践(5月31日)20155318 编写MyOD.java 用java MyOD XXX实现Linux下od -tx -tc XXX的功能 (码云链接) 代码 import java.io ...

  6. 北京Uber优步司机奖励政策(3月31日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  7. 北京Uber优步司机奖励政策(12月31日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  8. 成都Uber优步司机奖励政策(3月31日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  9. 成都Uber优步司机奖励政策(8月31日~9月6日)

    本周(8月31日-9月6日),优步成都继续推出丰厚保底奖励,日保底总金额最高575元,每周保底最高可获得3595元.优步还加大了乘客端折扣力度,最低五折坐车!单子超多,上线就有单,接单接不停!欢迎各位 ...

随机推荐

  1. Trace和Debug主要用法

    #region 日志记录 //System.Diagnostics.Trace.Listeners.Clear(); //System.Diagnostics.Trace.AutoFlush = tr ...

  2. bzoj3875

    悲伤地回忆,当初写了一个作死的算法爆零了为什么不好好写暴力呢……显然设w[i]表示彻底干掉这个怪物的代价注意发现这里的转移具有后效性,但是干掉每个怪物的最优值是一定的我们用spfa来转移,详见那篇sp ...

  3. POJ_1742_Coins_(动态规划,多重部分和)

    描述 http://poj.org/problem?id=1742 n种不同面额的硬币 ai ,每种各 mi 个,判断可以从这些数字值中选出若干使它们组成的面额恰好为 k 的 k 的个数. 原型: n ...

  4. Makefile中include、-include、sinclude的区别

    如果指示符“include”指定的文件不是以斜线开始(绝对路径,如/usr/src/Makefile...),而且当前目录下也不存在此文件:make将根据文件名试图在以下几个目录下查找:首先,查找使用 ...

  5. MonkeyRunner执行Python脚本实例——发送短信增强版

    很久之前就写好的了,准备写个自动执行Monkey的脚本时才想到去找它,还是写在博客里找起来方便. 这次更新了批处理自动连接设备后执行Py脚本,结构如下图: 其中shotscreen为存放截图文件夹,s ...

  6. Unity 中关于 BuildSetting 中 “Optimize Mesh Data” 选项的“坑”

    Unity 在底层默认希望为你做尽可能多的优化,降低使用门槛,比如 BuildSetting 中的 Optimize Mesh Data 选项就是一个典型的例子. 这个选项到底有什么用呢?文档描述为: ...

  7. Bzoj 2120: 数颜色 && 2453: 维护队列 莫队,分块,bitset

    2120: 数颜色 Time Limit: 6 Sec  Memory Limit: 259 MBSubmit: 2645  Solved: 1039[Submit][Status][Discuss] ...

  8. What does wildcard address in InetSocketAddress mean?

    In the docs for the constructor InetSocketAddress(int port) it says: Creates a socket address where ...

  9. Hyperic Agent 安装配置报 - No token file found, waiting for Agent to initialize

    本人经过跟VMWare 支持的多方努力,问题终于得到解决,方案如下: * Stop the agent Windows service. * Make sure all the agent proce ...

  10. composer 常用命令

    composer list 列出所有可用的命令 composer init 初始化 composer.json文件(就不劳我们自己费力创建啦),会要求输入一些信息来描述我们当前的项目,还会要求输入依赖 ...