metalhead41 Posted February 19, 2008 Share Posted February 19, 2008 Ok, I may need to do this in javascript but it doesn't hurt to ask here incase there is a php way The school I work for has alternating timetable weeks, e.g week a, week b. What I want to do is have a backed calender for the website (user's won't be able to see it), that has all the different timetable weeks, and holidays built into it. On the website itself, I would like to just display the date, time and week info that it pulls from the backend calender... Is this possible? or is it something that will only be able to be done in javascript? Thanks for your replies Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/ Share on other sites More sharing options...
metalhead41 Posted February 19, 2008 Author Share Posted February 19, 2008 Anyone have an idea? Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-471121 Share on other sites More sharing options...
revraz Posted February 19, 2008 Share Posted February 19, 2008 I see no reason why you can't do it with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-471131 Share on other sites More sharing options...
harristweed Posted February 19, 2008 Share Posted February 19, 2008 My thoughts are: If you only have week=a or week=b, get he week number using the date() function and if it'a an odd number week = a even week = b (or vise versa). Include the holiday weeks in a switch statement..... Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-471133 Share on other sites More sharing options...
metalhead41 Posted February 19, 2008 Author Share Posted February 19, 2008 My thoughts are: If you only have week=a or week=b, get he week number using the date() function and if it'a an odd number week = a even week = b (or vise versa). Include the holiday weeks in a switch statement..... Brilliant, how would I get the week number from date()? Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-471139 Share on other sites More sharing options...
metalhead41 Posted February 19, 2008 Author Share Posted February 19, 2008 Ok, forget that last question, 'twas a stupid one... However, how would I go about doing the switch statement for holidays etc? Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-471177 Share on other sites More sharing options...
harristweed Posted February 20, 2008 Share Posted February 20, 2008 Like this: <?php $week=date("W"); switch ($week) { case "20": // it's easter break; case "30": //summer holiday break; case "51": //Christmas break; default: if($week % 2){ //its week a $display = "week a"; }else{ //it's week b $display = "week b"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-471714 Share on other sites More sharing options...
metalhead41 Posted February 23, 2008 Author Share Posted February 23, 2008 Like this: <?php $week=date("W"); switch ($week) { case "20": // it's easter break; case "30": //summer holiday break; case "51": //Christmas break; default: if($week % 2){ //its week a $display = "week a"; }else{ //it's week b $display = "week b"; } } ?> Brilliant, just what I wanted thanks. Quote Link to comment https://forums.phpfreaks.com/topic/91947-help-with-date-function/#findComment-474418 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.