gpt4 book ai didi

php - 如何获得上一年的日期相对于一年中的一周

转载 作者:可可西里 更新时间:2023-11-01 00:48:15 25 4
gpt4 key购买 nike

如何获得同一天的同一天ISO-8601周数但在前一年使用 php?

我熟悉从时间戳中提取这种软信息。是否有一种内置方法可以让我从星期几、一年中的一周和一年转到时间戳?

最佳答案

您可以像这样结合使用 datestrtotime:

// get the timestamp
$ts = strtotime('today');

// get year, week number and day of week
list($year, $week, $dow) = explode('-', date('Y-W-N', $ts));

// use the "YYYY-WXX-ZZ" format
$format = ($year - 1) . "-W$week-$dow";
echo date('Y-m-d', strtotime($format)), PHP_EOL;

关于php - 如何获得上一年的日期相对于一年中的一周,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13337435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com