[PHP] Re: Calendar Problem

2009-08-11 Thread Shawn McKenzie
Shawn McKenzie wrote:
> tedd wrote:
>> Hi gang:
>>
>> I want to show the dates for all Fridays +-30 days from a specific date.
>>
>> For example, given today's date (8/11/2009) the Fridays that fall +-30
>> days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
>> Sept 4.
>>
>> I'm curious, how would you guys solve this?
>>
>> Cheers,
>>
>> tedd
> 
> Lots of ways to skin that cat, here is one:
> 
> $date = time(); //or whenever
> $start = strtotime('-30 days', $date);
> $end = strtotime('+30 days', $date);
> 
> $next = $start;
> while(($next = strtotime('Next Friday', $next)) <= $end) {
>   echo date("F j, Y", $next)."\n";
> }
> 

I must be bored:

for($next = strtotime('-30 days');
$next <= strtotime('+30 days');
$next = strtotime('Next Friday', $next))
{
echo date("F j, Y", $next)."\n";
}

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: Calendar Problem

2009-08-11 Thread Shawn McKenzie
tedd wrote:
> Hi gang:
> 
> I want to show the dates for all Fridays +-30 days from a specific date.
> 
> For example, given today's date (8/11/2009) the Fridays that fall +-30
> days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
> Sept 4.
> 
> I'm curious, how would you guys solve this?
> 
> Cheers,
> 
> tedd

Lots of ways to skin that cat, here is one:

$date = time(); //or whenever
$start = strtotime('-30 days', $date);
$end = strtotime('+30 days', $date);

$next = $start;
while(($next = strtotime('Next Friday', $next)) <= $end) {
echo date("F j, Y", $next)."\n";
}

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: Calendar Script

2005-01-03 Thread HarryG
Cool.. just tried your script. I might try to convert it to Smarty template 
compatible code, in my spare time. Have you used Smarty Templates??
  "Joe Harman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
  Hello,

  I just finished writing a basic calendar script... I wanted to pass it out to 
everyone here... maybe someone could use it... or, even better optimize it.. 
.and maybe share that with me.

  Next Month ";
 $link_prev_month = "Prev Month ";

// Table Size Variables... will be moved to CSS eventually
 $table_align = "center";
 $table_width = 500;
 $table_height = 50;
 $cell_width = $table_width/7;   
// Start HTML for Building Calendar

  $cal_generated .= "".$link_prev_month." 
".$link_next_month."";
  $cal_generated .= "";
  $cal_generated .=  "".$the_first_day_of_the_month['month']." 
".$the_first_day_of_the_month['year']."";
  $cal_generated .= "SunMon";
  $cal_generated .= "TueWedThu";
  $cal_generated .= "FriSat";
  
// Initial Calendar Buildin Variables
  $first_week_marked = FALSE;
  $month_day_count = 1;
  $week_day_count = 0;

// Start The Calendar Loop
  do {
if($mark_today_on_calendar == TRUE && $todays_date['mday'] == 
$month_day_count)
 { 
  $highlight_today_open = ""; 
  $highlight_today_close = "";
 }
else
 { 
  $highlight_today_open = ""; 
  $highlight_today_close = "";
 }
  
   // If it is the first day of the week open a ROW
if($week_day_count == 0)
  { 
   $cal_generated .= ""; 
  }

 if ($first_week_marked == FALSE)
  {
   $blank_cell = 0;
do {
 if($the_first_day_of_the_month['wday'] <> $blank_cell)
  {
   $cal_generated .= "";
   $blank_cell++;
  }
 else
  { 
   
   
   $cal_generated .= "".$highlight_today_open 
."".$month_day_count."".$highlight_today_close."";
   $first_week_marked = TRUE;
  }
  
$week_day_count = $the_first_day_of_the_month['wday'];
 
   } while ($first_week_marked == FALSE);

  }
 else
  {
   $cal_generated .= "".$highlight_today_open 
."".$month_day_count."".$highlight_today_close."";
  }

$month_day_count++;

// If it is the last day of the week close ROW
 if($week_day_count == 6)
  { 
   $cal_generated .= ""; 
  }
  
$week_day_count++;
   
// Countings 
 if($week_day_count == 7)
  {$week_day_count=0;}
  
  } while ($month_day_count <= $num_days_in_month);
   // End Calendar Loop
  
   $cal_generated .= "";   
   return $cal_generated;
 
   }

  echo Cal_Month();
  ?>

  Joe Harman


[PHP] Re: Calendar math .... how to count in week days....?

2004-05-14 Thread Anthony
The PEAR functions didn't seem to do what I was looking for.  I built this
function based on an idea given to me by  Daryl Meese.

After much trial and error, it actualy does what I need.  My function is
bassed on hours but you can easily change that.  It will add or subtract
days.
- Anthony

/* buisinessDays
 * Calculates a new date bassed on buisiness hours
 * vars: hours to adjust by, timestamp
 * returns: adjusted timestamp
 */
 function businessDays($hours,$date) {
  // this function assumes $date is a business day

  $dayHours=7.5; // set how many hours are in a day

  // set the days we need to adjust by.  there is a one day buffer
  $days=(abs($hours/$dayHours))+1;

  // weeks
  $adjust=604800 * floor($days / 5);

  // how many days are left over
  $remain=round($days % 5);

  // check for negative
  if ($hours<0) {
   // check to see if we will land on a weekend, and make appropriate
adjustment
   if (date("w",$date)<=$remain) {
$remain +=2;
   }
   // make the time adjustment, 8640 microseconds in a day, times the
remaining adjustment
   $date -=($adjust +(86400 * $remain));
  }
  else {
   // check to see if we will land on a weekend, and make appropriate
adjustment
   if ((6-date("w",$date))<=$remain) {
$remain+=2;
   }
   // make the time adjustment, 8640 microseconds in a day, times the
remaining adjustment
   $date +=($adjust +(86400 * $remain));
  }
  return $date;
 }

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



[PHP] Re: Calendar math .... how to count in week days....?

2004-05-06 Thread Torsten Roehr
"Anthony" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I've run into a bit of a problem, that I know has been dealt with before,
> but I don't know how to deal with it.  Very simple, I have an application
> that needs to do calendar math and do it specifically on business days.  I
> need to be able to add and subtract a number of days to only Monday though
> Friday.  Seems simple enough, but I can't figure out how to do it.  The
only
> think I've come up with so far is to build a function that counts every
day
> and checks to see if it's a weekend or not.  This wouldn't be all that
hard
> to do, but I'm wondering if there is a better way to do it?  Anyone have a
> really efficient function to do this, I need to figure out a LOT of dates
in
> this app.
>
> - Anthony

Hi Anthony,

take a look at PEAR's Calendar package:
http://pear.php.net/package/Calendar

There is a simple example for building a calendar. Maybe you can adapt it by
ignoring weekends:
http://pear.php.net/manual/en/package.datetime.calendar.intro-inahurry.php

Regards, Torsten

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



[PHP] Re: calendar class

2004-02-25 Thread Greg Beaver
http://pear.php.net/Calendar

Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org
John Taylor-Johnston wrote:
Anyone recommend a good calendar class at phpclasses.org or elsewhere?
Something I can install with ease and teach someone else to use and update using, oh 
say phpmyadmin?
Thanks,
John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Calendar Script

2003-10-29 Thread pete M
here's the calendar I use
http://dynarch.com/mishoo/calendar/index.html
pete

Vijay Killu wrote:
Dear PHP,

Where can I find the Calendar script that has been used on the PHP.net site.
I believe I can use it on my website since it is open source :-)
Thanks & Regards, 
___ 
PHPLover
 
*  : [EMAIL PROTECTED] 

"Göd döësn't pläy dícë." 
- Älbërt Ëínstëín


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


[PHP] Re: Calendar Tool

2003-10-28 Thread Matt Palermo
Oops...  The link to the site is:

http://www.sweetphp.com/projects/TotalCalendar/

Sorry.

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



[PHP] RE: Calendar showing availability of apartments/hotels

2003-06-05 Thread Dillon, John
PS I have not yet checked http://www.phpclasses.org (waiting for log in
details to come through), though I've looked through recent threads.

-Original Message-
From: Dillon, John 
Sent: 05 June 2003 11:59
To: [EMAIL PROTECTED]
Subject: Calendar showing availability of apartments/hotels


I'm looking for your recommendations for php scripts which will give me a
web based calendar for showing 'vacant', 'not available' or 'availability
unknown' states, based on days available for a particular apartment in the
database - eg for 'not available' perhaps the day is crossed out or in red
background, perhaps 'unknown' days are in yellow background etc.  I've seen
one that show perhaps the next 3-4 months on one page.  I have done my own
but I was looking for alternatives that I can adapt and plug into my
database.  Here's an example:

http://www.latelets.com/cal.php3?month=6&year=2003&ct_ref=20981&type=branded

I'm also looking for an easy way to update it, where you click on the day or
an icon and it changes state from 'unknown' to 'available' to 'not
available', which is javascript, but then you submit and it updates the
database.

Thanks for any suggestions.

John
































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are 
confidential. If you are not the named recipient please notify the sender and 
immediately delete it. You may not disseminate, distribute, or forward this e-mail 
message or disclose its contents to anybody else. Copyright and any other intellectual 
property rights in its contents are the sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept liability for any errors or omissions in the contents of 
this message which arise as a result of e-mail transmission.  If verification is 
required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and 
any attachments for viruses. We make no representation or warranty as to the absence 
of viruses in this e-mail or any attachments. Please note that to ensure regulatory 
compliance and for the protection of our customers and business, we may monitor and 
read e-mails sent to and from our server(s). 

For further important information, please read the  Important Legal Information and 
Legal Statement at http://www.cantor.com/legal_information.html


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



[PHP] Re: Calendar

2003-03-02 Thread Manuel Lemos
Hello,

On 03/01/2003 07:28 PM, Jason D. Williard wrote:
Is there an easy way to create a calendar in PHP, such as a calendar
function?  All I need is a dynamically created calendar to link to other
pages.
You may want to try this class that you customize in a sub-class to do 
whatever you want as demonstrated in the example:

http://www.phpclasses.org/calendarclass

--

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



[PHP] Re: calendar solution for workgroups ???

2002-12-23 Thread Jan Schneider
Tariq Murtaza wrote:

Hi all,
I am looking for a good calendar system for a group of people. (PHP /Mysql)
any idea??

Help/Comments will be appreciated.


Try http://www.horde.org/kronolith/

The newest version from CVS supports shared calendars and a fine 
granulated permission system based on users/groups.

Jan.


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



[PHP] Re: Calendar script - help

2002-11-05 Thread Kerry Kobashi
Your better off writing it from scratch than taking some pre-existing calendar/events 
code. Break the problem up into two seperate pieces and solve for each - the creation 
of a calendar view and the creation of a events view.

"I am a calendar and I know how to:"
  Show a monthly view of myself
  Move forward one month
  Move backward one month
  When a day is clicked I ask the events viewer to show an event

"I am a events viewer and I know how to:"
  Show a event
  Add a event
  Edit a event
  Delete a event

Create two classes, Calendar (calendar.php) and Events (events.php) that do the above.

The schema of the mySQL database is simple:

create table CalendarEvents
(
   eventId int unsigned NOT NULL auto_increment primary key,
   title varchar(64) NOT NULL,
   eventDateStart DATE default '-00-00',
   eventDateEnd DATE default '-00-00',
   event text NOT NULL
);

Instead of entering in a date, why not click on the calendar's day to take you to a 
form that will let you enter in the information. Here's some functions to helpin 
generating the calendar, which is nothing more than a 6 row by 7 column table. Figure 
out the start of the first day in the month via the FirstDayofMonth() function below. 
Create blank cells up to that day, then generate the numbered days, along with 
numbered day hyperlinks that when clicked, contain the month, day, year (e.g. 
hyperlink for the day contains Events.php?m=11d=5y=2002). This will create your 
context for the day. You will be able to $_GET the params from within Events.php. This 
will allow you to insert/delete/edit the record for that day in the database.


function IsLeapYear($year)
{
return(date("L", mktime(0,0,0,1,1,$year)));
}

function FirstDayofMonth($month, $year)
{
// 0 - Sunday 6 - Saturday
return(date("w", mktime(0,0,0,$month,1,$year)));
}

function DaysInMonth($month, $year)
{
return(date("t", mktime(0,0,0,$month,1,$year)));
}


Good luck,


Kerry Kobashi
Kobashi Computing

-

"Ray Healy )" <[EMAIL PROTECTED]> wrote in message 
news:001a01c2835e$f9234d40$601786d9@;mainserver...
Dear All

I spent days and days on this little project but still cannot get it to work (new to 
PHP as you might guess).

I have a script which is a combination of tutorial scripts and free code to display a 
calendar with colour coded cells for the events on each day.

The only way to enter events is to enter them one at a time. What I want to do is to 
be able to enter either a start date and end date or start date and the number of 
days. This will then enter a new line in the mySQL database for each day. There would 
only ever be one vent per day.

I have the following fields at present in the database and would probably need another 
field (say number of days)
id int (auto_increment) - eventdate date ('-00-00') - title (varchar) - event 
(blob)

Can anyone help me as I have searched them web and mail lists to no avail. Everything 
that is available is excellent but does too much for what I need.

Summary:- a calendar that can colour code the background cells if there is an event 
title in the mySQL database and to be able to enter the event for multiple days.

Any help would be very much appreciated.

Thanks for your time

Ray




[PHP] Re: Calendar

2001-10-26 Thread Philip Hallstrom

Check www.zend.com in the code gallery... I'm sure they have something
along these lines.

On Fri, 26 Oct 2001, Chip wrote:

> Does anyone know of a php script that will display a monthly calendar in
> a graphical format? I have a client that would prefer that over the typical
> list of dates which is much easier to do. I need to be able to put various
> bits of info on differant days of the month of course, and have links to all
> the months, in seperate calendar pages.
>
> --
> Chip W.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]