There are many kind of php function you can use for datetime manipulation. But today I will share a short code that you can use for get date of one week based on your week number.
I have created a function that you can use or develop
Let see my function below :
<?php function get_date_in_week($year,$week_number){ $date = array(); // 1 week 7 days for($day = 1; $day <= 7; $day++){ $set_date = strtotime($year."W".($week_number<10?'0':'').$week_number.$day); if(date('Y',$set_date) == $year){ $date['year-'.$year]['week-'.$week_number]['day-'.$day] = date('j', $set_date); } } return $date; } ?>
Now, you can simple to use, just call the function then you will get date of one week based on your week number.
<pre> <?php $year = '2013'; $week_number = '2'; print_r(get_date_in_week($year,$week_number)); ?> </pre>
The result will be like this :
Array ( [year-2013] => Array ( [week-2] => Array ( [day-1] => 7 [day-2] => 8 [day-3] => 9 [day-4] => 10 [day-5] => 11 [day-6] => 12 [day-7] => 13 ) ) )
Hope it can helps.
But if you still need help, just write your comment below.
I will try to find out.
Kind regard,
Bayu Prawira
No comments:
Post a Comment