时间函数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手册中还没有相应的内容 :
最新文章
- Oracle创建用户设置权限
- JavaScript 回忆录
- LeetCode OJ 274. H-Index
- Codeforces 369E Valera and Queries --树状数组+离线操作
- spark1.6配置sparksql 的元数据存储到postgresql中
- 加载.properties方式
- docker registry 搭建
- System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string, string)已过时的解决办法
- TortoiseGit - 处理冲突
- JavaScript数组基础及实例
- Numpy入门 - 行列式转置
- Spring Boot @EnableWebMvc 与 mvc 配置
- 关于浏览器对html, js,css的解析先后顺序的理解
- linux下安装mysql解决乱码、时间差、表的大小写问题
- Derek解读Bytom源码-P2P网络 地址簿
- appium API接口
- MySql 按周/月/日统计数据的方法
- 关于casperjs的wait方法的执行顺序
- 1. AutoEncoder介绍
- Logback中文文档(四):Appender