周数和周日 [英] Week number and Week day

查看:114
本文介绍了周数和周日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的date()生成的当前年和周日的周数。

I have week number of current year and week day generated by date() like this.

$week_number = date('W');
$week_day = date('w');

我需要格式化。如何获得本周的开始日期?或$ day_number和$ week_day的月份日期?

I need to format this. How can I get starting date of this week? Or day of month with $week_number and $week_day?

推荐答案

更新

也许这个文章可以帮助您。它描述了如何获取给定周的开始和结束日期。

Maybe this article helps you. It describes how to get the start and end date of a given week.

<?php
// Monday
echo date(
    datetime::ISO8601,
    strtotime("2006W37"));

// Sunday
echo date(
    datetime::ISO8601,
    strtotime("2006W377"));
?>

格式为< year> W< week-number>< ; daynumber> 和星期一是 1

更新2: / strong>

Update 2:

也许另一种可能性是使用 strtotime() 这样:

Maybe another possibility is to use strtotime() this way:

echo strtotime("last Monday");
echo strtotime("next Sunday");

您可以将其与 date()获取所需格式的日期。

You can combine this with date() to get the date in the desired format.

您可以通过日期('d')直接。

date()文档

这篇关于周数和周日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆