Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法

作者:刃起风啸凌   发布日期:2024-07-12   浏览:936

以下是获取今日、昨日、上周、本月起始时间戳和结束时间戳的方法:

  1. 获取今日起始时间戳和结束时间戳:

    $today_start = strtotime('today');
    $today_end = strtotime('tomorrow') - 1;
  2. 获取昨日起始时间戳和结束时间戳:

    $yesterday_start = strtotime('yesterday');
    $yesterday_end = strtotime('today') - 1;
  3. 获取上周起始时间戳和结束时间戳:

    $last_week_start = strtotime('last week');
    $last_week_end = strtotime('last week +6 days') + 86399;
  4. 获取本月起始时间戳和结束时间戳:

    $this_month_start = strtotime('first day of this month');
    $this_month_end = strtotime('last day of this month') + 86399;

注意:以上方法中,起始时间戳是指当天的 00:00:00 的时间戳,结束时间戳是指当天的 23:59:59 的时间戳。

上一篇:手把手编写自己的 PHP MVC 框架实例教程

下一篇:php中检测上传文件类型与上传图片大小代码

大家都在看

php session用法

php 定义常量

phpisset函数

php后端

php爬虫框架

php读取csv文件

php 三元表达式

php文件加密

php 拆分字符串

php pcntl

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站