本文实例讲述了PHP简单获取上月、本月、近15天、近30天方法。分享给大家供大家参考,具体如下:
/** * 获取统计时间 * @param $type * 1 上月 * 2 本月 * 3 近15天 * 4 近30天 * @return array */ function getDateInfo($type) { $data = array( array( 'firstday' => date('Ym01', strtotime('-1 month')), 'lastday' => date('Ymt', strtotime('-1 month')), ), array( 'firstday' => date('Ym01', strtotime(date("Y-m-d"))), 'lastday' => date('Ymd', strtotime((date('Ym01', strtotime(date("Y-m-d")))) . " +1 month -1 day")), ), array( 'firstday' => date('Ymd', strtotime("-15 day")), 'lastday' => date('Ymd', strtotime('-1 day')), ), array( 'firstday' => date('Ymd', strtotime("-30 day")), 'lastday' => date('Ymd', strtotime('-1 day')), ), ); return is_null($type) "htmlcode">Array ( [firstday] => 20170601 [lastday] => 20170630 )PS:这里再为大家推荐几款时间及日期相关工具供大家参考使用:
在线日期/天数计算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi在线日期计算器/相差天数计算器:
http://tools.jb51.net/jisuanqi/datecalc在线日期天数差计算器:
http://tools.jb51.net/jisuanqi/onlinedatejsqUnix时间戳(timestamp)转换工具:
http://tools.jb51.net/code/unixtime更多关于PHP相关内容感兴趣的读者可查看本站专题:《php日期与时间用法总结》、《PHP数组(Array)操作技巧大全》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《古筝与现代音乐的交织》1CD[MP3][96MB]
- 王俪婷.2011-ROMANCE【华研国际】【WAV+CUE】
- 狮子合唱团.2016-LION(引进版)【华纳】【WAV+CUE】
- 范文芳.1996-FNNTASY【HYPE】【WAV+CUE】
- 纯音入心系列纯音乐《韵味古筝曲》1CD[MP3][146.2MB]
- 纯音入心系列纯音乐《古筝系列-传统乐曲》1CD[MP3][974.7MB]
- 纯音入心系列纯音乐《古筝系列-弦凝指咽声停处》1CD[MP3][656.5MB]
- 群星.1994-大烂片2辑【派森】【WAV+CUE】
- 吴倩莲.1997-望爱【EMI百代】【WAV+CUE】
- 杨千嬅.2002-万紫千红演唱会2CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郭采洁.2015-Begin.Again爱造飞鸡【华纳】【FLAC分轨】
- 许志安.2011-ON.AND.ON【东亚】【WAV+CUE】
- 潘秀琼.1994-木兰从军【名将】【WAV+CUE】
- 纯音入心系列纯音乐《古筝系列-当流行乐遇到古筝》1CD[MP3][1.9GB]
- 纯音入心系列纯音乐《精选古筝名曲100首》1CD[MP3][388.7MB]