php - 获取本周的时间戳

标签 php oop datetime

我有当天的日期时间。我需要获得本周开始和结束的两个 unix 时间戳。如何使用 dateperiod 或 dateinterval 类?

最佳答案

$now = time();
$beginning_of_week = strtotime('last Monday', $now); // Gives you the time at the BEGINNING of the week
$end_of_week = strtotime('next Sunday', $now) + 86400; // Gives you the time at the END of the last day of the week

关于php - 获取本周的时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5449402/

相关文章:

c++ - 在C++中实现多个接口(interface)

MySQL 基于日期的条件插入或更新

PHP 和 MySQL ORDER BY date_time 错误

php - 如何计算包括当天在内的小时差

php - 在一行中显示具有重复用户 ID 的多条记录

php - 如何在js文件中写入php代码

php - 如果数据丢失则重定向到页面

node.js - Typescript:在子方法中覆盖父类的静态工厂方法

php - 在哪里存储我的 OOP 类需要的巨大常量

php - 如何在 Drupal 中缓存 PHP 生成的 XML 文件?