I have week number of current year and week day generated by date() like this.
$week_number = date('W');
$week_day = date('w');
I need to format this. How can I get starting date of this week? Or day of month with $week_number and $week_day?
I have week number of current year and week day generated by date() like this.
$week_number = date('W');
$week_day = date('w');
I need to format this. How can I get starting date of this week? Or day of month with $week_number and $week_day?
Update:
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"));
?>
Where the format is <year>W<week-number><daynumber>
and Monday is 1
.
Update 2:
Maybe another possibility is to use strtotime()
this way:
echo strtotime("last Monday");
echo strtotime("next Sunday");
You can combine this with date()
to get the date in the desired format.
You can get the day of the month with date('d')
directly.