note 77967 added to function.date
| From: | sheldon at gozipline dot com | Date: | Fri, 21 Sep 2007 18:41:31 +0000 |
| Subject: | note 77967 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130676@lists.php.net to get a copy of this message | ||
I have to work out the day before an event to send an email notification. But if the day before was
on a weekend I had to make sure the email was send on the Friday before the weekend. I didn't
see anything like this around so here is what i wrote.
Hope it helps some one else.
<?php
$dates = explode("/", "09/22/2007");
$month = $dates['0'];
$day = $dates['1'];
$year = $dates['2'];
$yesterday = mktime(0,0,0,$month,$day-1,$year);
$notification = date('l',$yesterday);
if(in_array($notification, array("Saturday", "Sunday"))){
$notification = "Friday";
}
echo("<p>{$notification}</p>");
?>
----
Server IP: 209.41.74.194
Probable Submitter: 67.185.1.198
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/77967
Del: integrated -- https://master.php.net/note/delete/77967/integrated
Del: useless -- https://master.php.net/note/delete/77967/useless
Del: bad code -- https://master.php.net/note/delete/77967/bad+code
Del: spam -- https://master.php.net/note/delete/77967/spam
Del: non-english -- https://master.php.net/note/delete/77967/non-english
Del: in docs -- https://master.php.net/note/delete/77967/in+docs
Del: other reasons-- https://master.php.net/note/delete/77967
Reject -- https://master.php.net/note/reject/77967
Search -- https://master.php.net/manage/user-notes.php