php3-list | 199901
Date: 01/30/99
- Next message: Richard Lynch: "Re: [PHP3] Help : Newby !!!!"
- Previous message: Mark Jeftovic: "Re: [PHP3] Shell in background?"
- Maybe in reply to: hoakes <email protected>: "[PHP3] Date question: How to check if today is the last Saturday?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 7:52 AM 1/30/99, hoakes <email protected> wrote:
>Hello-
>
>I am working on a reminder system in PHP, and I would like people
>to be able to schedule reminders for the first, second, third,
>fourth and last $day_of_week.
>
>I have the first, second...etc. stored in a db as well as the
>day_of_week. The PHP script will go thru all the reminders early
>in the morning, and create a list of the day's reminders. I am
>trying to figure out how to check the day to see if it is the
>first, second...etc. Any Ideas? Does this make any sense?
You'll basically have to play games with mktime and date.
//Untested code:
// Step 1: Find the last day of *this* month:
$today = mktime();
$month = date("m", $today);
$year = date("Y, $today);
$end = 31;
#Note that mkdate will force the date to be valid.
$lastdate = mkdate(0, 0, 0, $month, $end, $year);
$endsmonth = date("m", $lastdate);
while ($endsmonth != $month){
$end--;
$lastdate = mkdate(0, 0, 0, $month, $end, $year);
$endsmonth = date("m", $lastdate);
}
//Now visit the last Seven days of this month
$lastdays = array();
for ($i = 1, $e = $lastdate; $i < 7; $i++, $e--){
$lastdays[date("D", $e)] = $e;
}
/*
$lastdays['Sun'] = <the date on which the last Sunday falls>;
$lastdays['Mon'] = <the date on which the last Monday falls>;
*/
Or, if you just want to check for what today's date is, change the last 3
lines to:
for ($i = 1, $e = $lastdate; $i < 7; $i++, $i--){
if ($e == $today){
$last_day_of_month = date("D", $e);
//Check reminders for today with $last_day_of_month in them.
}
}
-- "TANSTAAFL" Rich lynch <email protected> webmaster@ and www. all of:
R&B/jazz/blues/rock - jademaze.com music industry org - chatmusic.com
acoustic/funk/world-beat - astrakelly.com sculptures - olivierledoux.com
my own nascent company - l-i-e.com cool coffeehouse - uncommonground.com
-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>
- Next message: Richard Lynch: "Re: [PHP3] Help : Newby !!!!"
- Previous message: Mark Jeftovic: "Re: [PHP3] Shell in background?"
- Maybe in reply to: hoakes <email protected>: "[PHP3] Date question: How to check if today is the last Saturday?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

