当前位置: 首页 > news >正文

php获取,昨,今,后天.... 本周,月,年...日期时间戳

时间戳->时间转换工具

时间戳(Unix timestamp)转换工具 - 在线工具 (tool.lu)

代码如下:

    public function date(){/** 日期 **/// 今天的日期$result['today_date'] = date("Y-m-d");// 昨天的日期$result['yesterday_date'] = date("Y-m-d", strtotime("-1 day"));// 前天的日期$result['before_yesterday_date'] = date('Y-m-d', strtotime('-2 days'));// 本周的起始日期(周一)$result['week_start_date'] = date('Y-m-d', strtotime('monday this week'));// 本周的结束日期(周日)$result['week_end_date'] = date('Y-m-d', strtotime('sunday this week'));// 本月的起始日期$result['month_start_date'] = date('Y-m-01');// 本月的结束日期$result['month_end_date'] = date('Y-m-t');// 本年的起始日期$result['year_start_date'] = date('Y-01-01');// 本年的结束日期$result['year_end_date'] = date('Y-12-31');// 明天的日期$result['tomorrow_date'] = date('Y-m-d', strtotime('+1 day', strtotime(date("Y-m-d"))));// 后天的日期$result['after_tomorrow_date'] = date('Y-m-d', strtotime('+2 days', strtotime(date("Y-m-d"))));// 7 天后的日期$result['seven_days_after_date'] = date('Y-m-d', strtotime('+7 days', strtotime(date("Y-m-d"))));// 1 个月后的日期$result['month_after_date'] = date('Y-m-d', strtotime('+1 month', strtotime(date("Y-m-d"))));// 1 年后的日期$result['year_after_date'] = date('Y-m-d', strtotime('+1 year', strtotime(date("Y-m-d"))));/** 时间戳 **/// 今天的时间戳$result['today_time'] = strtotime(date("Y-m-d"));// 昨天的时间戳$result['yesterday_time'] = strtotime("-1 day", strtotime(date("Y-m-d")));// 前天的时间戳$result['before_yesterday_time'] = strtotime("-2 days", strtotime(date("Y-m-d")));// 本周的起始日期(周一)的时间戳$result['week_start_time'] = strtotime('monday this week');// 本周的结束日期(周日)的时间戳$result['week_end_time'] = strtotime('sunday this week');// 本月的起始日期的时间戳$result['month_start_time'] = strtotime(date('Y-m-01'));// 本月的结束日期的时间戳$result['month_end_time'] = strtotime(date('Y-m-t'));// 本年的起始日期的时间戳$result['year_start_time'] = strtotime(date('Y-01-01'));// 本年的结束日期的时间戳$result['year_end_time'] = strtotime(date('Y-12-31'));// 明天的时间戳$result['tomorrow_time'] = strtotime('+1 day', strtotime(date("Y-m-d")));// 后天的时间戳$result['after_tomorrow_time'] = strtotime('+2 days', strtotime(date("Y-m-d")));// 7 天后的时间戳$result['seven_days_after_time'] = strtotime('+7 days', strtotime(date("Y-m-d")));// 1 个月后的时间戳$result['month_after_time'] = strtotime('+1 month', strtotime(date("Y-m-d")));// 1 年后的时间戳$result['year_after_time'] = strtotime('+1 year', strtotime(date("Y-m-d")));/** 区间段时间戳 **/// 今天的开始时间戳和结束时间戳$result['today_start_time'] = strtotime('today');$result['today_end_time']   = strtotime('tomorrow') - 1;// 昨天的开始时间戳和结束时间戳$result['yesterday_start_time'] = strtotime('yesterday');$result['yesterday_end_time']   = strtotime('today') - 1;// 前天的开始时间戳和结束时间戳$result['day_before_yesterday_start_time'] = strtotime('-2 days', strtotime('today'));$result['day_before_yesterday_end_time']   = strtotime('yesterday') - 1;// 上周的时间戳(从上周一到上周日)$result['last_week_start_time'] = strtotime('last week monday');$result['last_week_end_time']   = strtotime('last week sunday') + 86399; // 86399 秒是一天的最后一秒// 一个月前的时间戳(从一个月前的第一天到最后一天)$result['last_month_start_time'] = strtotime('first day of last month midnight');$result['last_month_end_time']   = strtotime('last day of last month 23:59:59'); // 最后一天的最后一秒// 明天的开始时间戳和结束时间戳$result['tomorrow_start_time'] = strtotime('tomorrow');$result['tomorrow_end_time']   = strtotime('tomorrow +1 day') - 1;// 后天的开始时间戳和结束时间戳$result['day_after_tomorrow_start_time'] = strtotime('+2 days midnight');$result['day_after_tomorrow_end_time']   = strtotime('+2 days 23:59:59');// 本周的开始时间戳和结束时间戳(从本周一到本周日)$result['this_week_start_time'] = strtotime('monday this week');$result['this_week_end_time']   = strtotime('sunday this week') + 86399;// 下周的开始时间戳和结束时间戳(从下周一到下周日)$result['next_week_start_time'] = strtotime('monday next week');$result['next_week_end_time']   = strtotime('sunday next week') + 86399;// 下个月的开始时间戳和结束时间戳(从下个月的第一天到最后一天)$result['next_month_start_time'] = strtotime('first day of next month midnight');$result['next_month_end_time']   = strtotime('last day of next month 23:59:59');dump($result);exit();}

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 1.浅谈蓝牙BLE的总体框架
  • 【Mark笔记】基于Centos7.7更改SSH端口重启服务报错
  • SAP S4 销售组的定义和分配
  • WGS84坐标转换代码(JS版)
  • KVM虚拟机添加USB转串口设备
  • Github获8k Star!入选苹果CoreML模型库的Depth Anything是怎么做出来的?
  • 【D3.js in Action 3 精译】1.3 D3 视角下的数据可视化最佳实践(上)
  • 数据结构day6链式队列
  • 多位冒充者曝光!全域外卖官方到底是谁?
  • 谷粒商城实战-25-分布式组件-SpringCloud Alibaba-Nacos配置中心-加载多配置集
  • 华盈生物-PhenoCycler-超多靶标揭示组织空间位置和互作关系
  • centos磁盘空间满了-问题解决
  • 流程管理与商务智能解决方案(62页PPT)
  • 编程社团研究内容怎么写
  • 原生android的内存性能提升方面的测试和优化方案大致设计
  • android 一些 utils
  • android高仿小视频、应用锁、3种存储库、QQ小红点动画、仿支付宝图表等源码...
  • android图片蒙层
  • create-react-app做的留言板
  • HTML中设置input等文本框为不可操作
  • HTTP 简介
  • idea + plantuml 画流程图
  • iOS动画编程-View动画[ 1 ] 基础View动画
  • Java 9 被无情抛弃,Java 8 直接升级到 Java 10!!
  • Webpack入门之遇到的那些坑,系列示例Demo
  • 从零开始在ubuntu上搭建node开发环境
  • 蓝海存储开关机注意事项总结
  • 目录与文件属性:编写ls
  • 日剧·日综资源集合(建议收藏)
  • 问:在指定的JSON数据中(最外层是数组)根据指定条件拿到匹配到的结果
  • 原生Ajax
  • 走向全栈之MongoDB的使用
  • 如何通过报表单元格右键控制报表跳转到不同链接地址 ...
  • 通过调用文摘列表API获取文摘
  • ​ubuntu下安装kvm虚拟机
  • ​低代码平台的核心价值与优势
  • #HarmonyOS:Web组件的使用
  • (补充)IDEA项目结构
  • (二)fiber的基本认识
  • (附源码)springboot教学评价 毕业设计 641310
  • (附源码)ssm高校社团管理系统 毕业设计 234162
  • (论文阅读23/100)Hierarchical Convolutional Features for Visual Tracking
  • .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划
  • .Net 中的反射(动态创建类型实例) - Part.4(转自http://www.tracefact.net/CLR-and-Framework/Reflection-Part4.aspx)...
  • .NET 中小心嵌套等待的 Task,它可能会耗尽你线程池的现有资源,出现类似死锁的情况
  • .Net的C#语言取月份数值对应的MonthName值
  • .NET高级面试指南专题十一【 设计模式介绍,为什么要用设计模式】
  • @font-face 用字体画图标
  • @TableLogic注解说明,以及对增删改查的影响
  • [ JavaScript ] JSON方法
  • [20171101]rman to destination.txt
  • [2544]最短路 (两种算法)(HDU)
  • [android] 看博客学习hashCode()和equals()
  • [Angular] 笔记 9:list/detail 页面以及@Output
  • [C puzzle book] types