I am building a PHP calendar that has a week view and also a primary month view. I have a database which stores all events for everyday, and loads everything at start for the month.
The month view is complete and works fine, let me show you how it works:
Query to withdraw all events in that month:
WHERE a.target_date BETWEEN $month_start AND $month_end
$source_date = mktime(0,0,0,$month,1,$year);
$days_in_month = date("t",$source_date);
$month_start = mktime(0,0,0,$month,1,$year);
$month_end = mktime(23,59,0,$month,$days_in_month,$year);
Note that
$month and $year are determined in the URL, so that isn't a problem
My problem, I wish to use the same logic to withdraw all my events in the current week. However I am not certain how I can do this.
I am able to find the week number we are in the month with this code:
$current_date = time();
$current_date = date("Y-m-d",$current_date);
$week = get_weeks($current_date, "monday");
No comments:
Post a Comment