时间函数strtotime的强大
转载:php的strtotime举例-lsstarboy-ChinaUnix博客
1、上周日午夜
strtotime("last sunday");
2、本周日午夜
strtotime("this sunday");
3、今天午夜
strtotime("today");
4、昨天午夜
strtotime("yesterday");
5、上周同一时间
strtotime("-1 week");
6、上月第一天午夜:
strtotime("first day of last month midnight");
注意:不带midnight的话,就是上月第一天这个时候的秒数!
7、本月第一天午夜
strtotime("first day of this month midnight");
8、本年第一天午夜
strtotime("first day of jan");
注意,下面的结果是错误的,是本月的第一天:
strtotime("first day of year midnight");
9、指定日期:
strtotime("2011-01-01 midnight");
10、strtotime("first day of last year midnighth");会出现什么?
切记:会出现上年上个月份最后一天!
实际的测试:好像last和first都不能针对年,只对月有效
- 文档中的说明也有错误:
strtotime('last day of this year') doesn't work because last day of is only for month
use strtotime('-1 day', strtotime('first day of next year')) or anything else
- PHP官方关于时间描述的文档页,在php手册中还没有相应的内容 :
时间函数strtotime的强大的更多相关文章
- PHP的时间函数strtotime
时间加减 [php] view plaincopy <?php //获取本地 提取年份+1 $date=date("Y-m-d",mktime(0,0,0,date(&quo ...
- 玩转PHP(二)--PHP强大的时间函数:date()
PHP具有相对来说强大的时间函数date(),该方法有下列一系列参数: 例如: echo date("Y-m-d H:i:s"); //2015-01-09 13:03:30 如果 ...
- php函数strtotime结合date时间修饰语的使用
下面简单介绍在项目开发中date时间函数和strtotime所遇到的问题,以及解决办法. 原文地址:小时刻个人技术博客 > http://small.aiweimeng.top/index.ph ...
- 时间段(今天,昨天,本周,上周,本月,上月,总)的查询,时间处理函数strtotime
需求:最近get了一个很好用的PHP关于时间的函数strtotime,因为最近有个项目涉及到很多时间段(今天,昨天,本周,上周,本月,上月,总)的查询,要根据指定时间算出它每个范围的开始时间和结束时间 ...
- PHP中日期时间函数date()用法总结
date()是我们常用的一个日期时间函数,下面我来总结一下关于date()函数的各种形式的用法,有需要学习的朋友可参考. 格式化日期date() 函数的第一个参数规定了如何格式化日期/时间.它使用字母 ...
- php内置函数,时间函数,字符串函数
字符数----某一种编码下的一个文字 字节数----8位的0或1或者混合组成:显然字节占的空间大,显然一个字符至少占有一个字节,中文在utf-8至少占用3个也有可能4个字节 由上图可见,substr( ...
- 分享一些关于PHP时间函数的常用时间
<?php // 各种时间函数 echo "现在:".date("Y-m-d H:i:s")."<br>"; echo & ...
- date时间函数
时间函数: date();和time();的相互转换 time(); 在PHP中单位是秒,在js中是毫秒. microtime(); 毫秒 date('Y-m-d H:i:s',time()); ...
- php日期时间函数和数学函数
<?php //第一部分:日期和时间函数 ----------------------------- time(); //int time(void),返回当前时间的时间戳 mktime(); ...
- php日期时间函数 整理
设定系统默认时区 date_default_timezone_get() $tz='America/Los_Angeles'; 返回系统默认时区 date_default_timezone_set($ ...
随机推荐
- Dynamics365 DOC
Sample: Early-bound table operationshttps://docs.microsoft.com/en-us/powerapps/developer/data-platfo ...
- 【C学习笔记】day3-3 编写程序数一下 1到 100 的所有整数中出现多少个数字9
#include <stdio.h> int main() { int cou=0; for (int i = 1; i <= 100; i++) { if (i % 10 == 9 ...
- Java--Comparable接口实现,控制数组和列表的排序
实现Comparable 接口,可以获得的排序方法有 列表排序 Collections.sort(); 数组排序 Arrays.sort(); sort()方法中的参数是可以获取排序索引的对象或者按照 ...
- 如何简化跨网络安全域的文件发送流程,大幅降低IT人员工作量?
为什么要做安全域的隔离? 随着企业数字化转型的逐步深入,企业投入了大量资源进行信息系统建设,信息化程度日益提升.在这一过程中,企业也越来越重视核心数据资产的保护,数据资产的安全防护成为企业面临的重大挑 ...
- leetcode刷题(一)
1.数组 三数之和 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组. 注意:答案中不可 ...
- ibatis批量数据入库sql
ibaits 批量数据入库sql <insert id="waiter.insertBatch" parameterClass="java.util.List&qu ...
- 复习第7点-7.SpringMVC 的响应方式
1.使用ServletAPI实现转发 /* 使用HttpServletRequest对象实现请求转发 */ @RequestMapping("/httpServletRequest" ...
- monkey自动化脚本
获取第三方安装包:手机需root,adb shell>cd data/app>ls(获取相应app信息)>cd +相应app信息>base.apk(安装包) 获取第三方安装包: ...
- ubuntu配置phpmyadmin
之前已经把LNMP环境搭建好了 安装: sudo apt-get install phpmyadmin 安装必要依赖 sudo apt-get install php-mbstring sudo ap ...
- nginx客户端真实IP配置
https://www.cnblogs.com/kevingrace/p/8269955.html include mime.types; default_type application/octet ...