Jump to content

Help with date function


metalhead41

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/91947-help-with-date-function/
Share on other sites

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()?

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"; 
       }
       
  }
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.