Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2147
| From | Mark Lloyd <mlloyd@notroachstupid.usant.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Brilliance requested - calculating a date next month |
| Date | 2011-06-13 14:46 -0500 |
| Organization | Newshosting.com - Highest quality at a great price! www.newshosting.com |
| Message-ID | <1bpcv61varurd3pqslfvqarchm9hh27074@4ax.com> (permalink) |
| References | <6NKdnWtJdY6Nk2jQnZ2dnUVZ_j-dnZ2d@cablespeedmi.com> |
On Sun, 12 Jun 2011 15:05:48 -0400, bill <nobody@spamcop.net> wrote: >I am quietly banging my head on the wall. In concept it seems so >simple: > >I need to calculate the date of an appointment next month. >but: > it needs to be on the same day of the month, > eg: from the 2nd Tuesday of this month to the 2nd Tuesday of >next month. I handle meetings which are always on the 2nd Thursday of the month. I have a simple way to calculate the date of next month's meeting if I know this months'. It should work the same for Tuesdays: 1. $day_of_next_months_meeting = $day_of_this_months_meeting 2. $excess = $days_in_current_month - 28 3. $day_of_next_months_meeting -= $excess 4. if ($day_o f_next_months_meeting < 8) $day_of_next_months_meeting += 7 //make sure its in the second week For example, 2nd Tuesday in June is 14 Step 1: 14 Step 2: 2 (June has 2 more days than a whole number of weeks) Step 3: 12 Step 4: 12 (in this case, July 12 is the 2nd Tuesday) -- Mark Lloyd http://notstupid.us "If God wants us to do a thing, He should make his wishes sufficiently clear. Sensible people will wait till He has done this before paying much attention to Him." -- Samuel Butler
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Brilliance requested - calculating a date next month bill <nobody@spamcop.net> - 2011-06-12 15:05 -0400
Re: Brilliance requested - calculating a date next month Michael Fesser <netizen@gmx.de> - 2011-06-12 21:46 +0200
Re: Brilliance requested - calculating a date next month bill <nobody@spamcop.net> - 2011-06-13 06:46 -0400
Re: Brilliance requested - calculating a date next month Mathieu Maes <mathieu@webberig.be> - 2011-06-12 12:49 -0700
Re: Brilliance requested - calculating a date next month bill <nobody@spamcop.net> - 2011-06-12 16:43 -0400
Re: Brilliance requested - calculating a date next month Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-06-13 00:53 +0000
Re: Brilliance requested - calculating a date next month Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-06-13 13:00 +0000
Re: Brilliance requested - calculating a date next month Luuk <Luuk@invalid.lan> - 2011-06-12 22:59 +0200
Re: Brilliance requested - calculating a date next month Chuck Anderson <cycletourist@invalid.invalid> - 2011-06-12 20:11 -0600
Re: Brilliance requested - calculating a date next month bill <nobody@spamcop.net> - 2011-06-13 07:36 -0400
Re: Brilliance requested - calculating a date next month Mark Lloyd <mlloyd@notroachstupid.usant.invalid> - 2011-06-13 14:46 -0500
Re: Brilliance requested - calculating a date next month BootNic <bootnic.bounce@gmail.com> - 2011-06-13 17:59 -0400
csiph-web