周数和周日

时间:2010-03-03 15:07:08

标签: php date formatting

我有按日期()生成的当前年份和工作日的周数。

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

我需要格式化这个。我怎样才能获得本周的开始日期?或者是$ week_number和$ week_day的月份?

1 个答案:

答案 0 :(得分:3)

<强>更新

也许this article会帮助你。它描述了如何获得给定周的开始和结束日期。

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

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

格式为<year>W<week-number><daynumber>且周一为1

更新2:

也许另一种可能性就是以这种方式使用strtotime()

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

您可以将其与date()结合使用,以获得所需格式的日期。


您可以直接使用date('d')获取当月的日期。

date() documentation