i was able to generate a weekly report using some date function. The table looks like
-------------------------------------------------------------------------
week |Sunday |Monday |Tuesday |Wednesday |Thursday |Friday |Saturday |
|July 21 |July 22 |July 23 |July 24 |July 25 |July 26 |July 27 |
-------------------------------------------------------------------------
but whenever the current week consists of 2 months, like end of July and start of August. i am unable to find the current week. The table looks like
-------------------------------------------------------------------------
week |Sunday |Monday |Tuesday |Wednesday |Thursday |Friday |Saturday |
|July 28 |July 29 |July 30 |July 31 |July 32 |July 33 |July 34 |
-------------------------------------------------------------------------
please help. The result should look like
--------------------------------------------------------------------------
week |Sunday |Monday |Tuesday |Wednesday |Thursday |Friday |Saturday |
|July 28 |July 29 |July 30 |July 31 |August 1 |August 2 |August 3 |
--------------------------------------------------------------------------
I assume you have the first day of the week as a starting point?
Then use phps stringtotime
to easily progress in days:
<?php
$startOfWeek = date("Y-m-d", strtotime("Monday this week"));
for ($i=0; $i<7;$i++){
echo date("l, d M", strtotime($startOfWeek . " + $i day"))."<br />";
}
?>
Output:
Monday, 29 Jul
Tuesday, 30 Jul
Wednesday, 31 Jul
Thursday, 01 Aug
Friday, 02 Aug
Saturday, 03 Aug
Sunday, 04 Aug
format as required.
Update to your Question:
//find week start
$weekstart = date("Y-m-d", strtotime("Monday this week")) ;
echo $weekstart;
strtotime
is pretty flexible .
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments