Re: Date/Time Display for recurring monthly event

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aragon@HELP wrote:
Burhan,

Thank you for replying, it is very much appreciated.
	Perhaps I did not state what I needed as well as I should have. I'm
looking for the code which displays the date of the second Thursday of each
month on a web page. I have to insert this code at 5 different locations on
that webpage for different meetings. The scenario below describes how it
needs to work.

	This month for example, September, the second Thursday is September
8, 2005. Up until midnight of September 8th the date on the webpage should
read September 8, 2005. When midnight arrives on September 8th, the date
displayed should change to October 13, 2005. If you can still help me I
would be grateful.

Oh, so you want to display the next available Thursday.

<?php
$current_month_thursday = strtotime("2nd Thursday",mktime(0,0,0,date("m")-1,0,2005));
  if (strtotime("now") > $current_month_thursday)
  {
      //First thursday has passed, show the first thursday
      //of the next month

      echo 'Next Meeting Date : ';
      $next_month = mktime(0,0,0,date("m")+1,0,date("Y"));
      echo date("r",strtotime("2nd Thursday",$next_month));
  } else {
     // This month's second thursday hasn't passed yet
     echo date("r",$current_month_thursday);
  }
?>

This prints :

burhan@sandbox ~ $ php -q date2.php

Next Meeting Date : Thu, 13 Oct 2005 00:00:00 +0300

Hope this helps, and please, reply to the list and not directly to me so others may contribute and learn.

Regards,
Burhan




Aragon@HELP

-----Original Message-----
From: Burhan Khalid [mailto:phplist@xxxxxxxxxxxx] Sent: Sunday, September 11, 2005 6:55 AM
To: Aragon@HELP
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  Date/Time Display for recurring monthly event

Aragon@HELP wrote:

Having a heck of time getting anything to work, can anyone make a

suggestion

to the following.

I need a webpage that displays 5 recurring meeting dates, i.e. the second
Wednesday, Thursday, and Friday of each month in five different locations.


<?php

   echo "Current Month: \n\n";
   echo date("r",strtotime("second Wednesday"))."\n";
   echo date("r",strtotime("second Thursday"))."\n";
   echo date("r",strtotime("second Friday"))."\n\n";

   echo "Next Month: \n\n";
echo date("r",strtotime("second Wednesday",strtotime("1st October")))."\n"; echo date("r",strtotime("second Thursday",strtotime("1st October")))."\n"; echo date("r",strtotime("second Friday",strtotime("1st October")))."\n\n";

   echo "For all months of the year (for loop way) : \n\n";
   for($x = 1; $x <=12; ++$x)
   {
     $current_month = date("F",mktime(0,0,0,$x,1,date("Y")));
     echo 'For the month of '.$current_month.":\n\n";
echo date("r",strtotime("second Wednesday",strtotime("1st ".$current_month)))."\n"; echo date("r",strtotime("second Thursday",strtotime("1st ".$current_month)))."\n"; echo date("r",strtotime("second Friday",strtotime("1st ".$current_month)))."\n\n";
   }

   echo "For all months of the year (array_map way) : \n\n";

   function findDates($month)
   {
     $current_month = date("F",mktime(0,0,0,$month,1,date("Y")));
$x[] = date("r",strtotime("second Wednesday",strtotime("1st ".$current_month))); $x[] = date("r",strtotime("second Thursday",strtotime("1st ".$current_month))); $x[] = date("r",strtotime("second Friday",strtotime("1st ".$current_month)));
     return $x;
   }

   $dates = array_map('findDates',range(1,12));
   echo 'For the month of December : '."\n";
   print_r($dates[11]);

?>

Enjoy :)

--
Burhan





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux