rush_tech Posted November 4, 2011 Posted November 4, 2011 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
jamiess Posted November 9, 2011 Posted November 9, 2011 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 1
rush_tech Posted November 9, 2011 Author Posted November 9, 2011 Cheers Jamie, if you don't mind I'll have a look
jamiess Posted November 14, 2011 Posted November 14, 2011 @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
nickbro Posted November 14, 2011 Posted November 14, 2011 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)
jamiess Posted November 15, 2011 Posted November 15, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now