Jump to content

Recommended Posts

Posted

We have recently moved to a 2 week timetable and I've been asked to display which week we are on the website. I could go through the calendar and add it to the beginning of each week but I wanted to ask if anyone else does this and if there is a different method.

I'm using Joomla 1.5.24

Thanks

Posted

This is possible with php the only problem is holidays and how your two week timetable handles these. Ill dig out the code if you want to have a play.

 

Jamie

  • Thanks 1
Posted

@rush_tech, i have sorted the code out for you however i wont be in the right office until Wednesday, ill uploaded it for as soon as i get in. Hope this is ok.

 

Jamie

Posted

If you use home access plus, you can ask it what week you are in. Using an iframe on your website, you can create a page in HAP+ say, ~/bookingsystem/weeknumber.aspx

 

<%@ Page Language="C#" %>
<%=new HAP.Data.BookingSystem.BookingSystem().DayNumber.ToString()%>

or

<%@ Page Language="C#" %>
<%=new HAP.Data.BookingSystem.BookingSystem().WeekNumber.ToString()%>

 

Day Number: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Week Number: 1, 2, 0 (0 = Holiday)

Posted

Here is the code to do this in PHP

 

// set up an array
$dates = array();
//start date for the year
$start_date = "2011-09-05";
//end date for the year
$end_date = "2012-07-21";
//which week number to start on
$num = 1;

while ($start_date <= $end_date) {
// Split the given date down into day, month, and year
list($yy,$ym,$yd) = explode('-', $start_date);
// work out the week number
$weeknum = ltrim(date('W',mktime(0,0,0,$ym,$yd,$yy)), '0');
// write it to the array
$dates[$weeknum] = $num;
// Ternary operator to alternate the week number
$num = ($num == 1) ? 2 : 1;	
// increase the start date by 7 days for the next week
$start_date = date('Y-m-d',mktime(0,0,0,$ym,$yd+7,$yy));
}
//print out the array for all the weeks in the year
//print_r($dates);




// work out modays date from todays date
$date = date('Y-m-d', mktime(0,0,0,date('m'), date('d')-date('w')+1, date('Y')));
//explode it 
list($year,$month,$day) = explode('-', $date);
//work out our week number
$weeknum = date('W',mktime(0,0,0,$month,$day,$year));
//echo out the result
echo "
This week is week ". $dates[$weeknum] ."";

 

Hope this helps, Jamie

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...