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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.