note 49196 added to function.date
| From: | xsmokex at chello dot at | Date: | Wed, 19 Jan 2005 19:53:53 +0000 |
| Subject: | note 49196 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83639@lists.php.net to get a copy of this message | ||
i had to make a function that checks if a file in dmY.txt format exist if yes create d+1mY.txt as
there isnt such function!?
i wrote my own
perhabs usefull maybe for a calendar? as it returns valid dates without knowing when month/year ends
:)
<?php
function nextday($day,$code) {
$tempvalue = "+".$day." day";
$tempdate = getdate(strtotime($tempvalue));
$rday = $tempdate['mday'];
if (strlen($rday) == 1) {
$rday = "0".$rday;
}
$rmon = $tempdate['mon'];
if (strlen($rmon) == 1) {
$rmon = "0".$rmon;
}
$ryear = $tempdate['year'];
if ($code == "T") {
return $rday.".".$rmon.".".$ryear;
}
if ($code == "C") {
return $rday.$rmon.$ryear;
}
}
?>
(c for code t for text anyway u could edit it in whatever way u want)
Today 19.01.2005
$testdate = nextday(1,T);
echo $testdate;
echo "<br>\n";
$testdate = nextday(15,C);
echo $testdate;
would return
20.01.2005
03022005
hope its usefull for someone
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49196
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49196&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49196&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49196&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49196&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49196&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49196&report=yes
Search -- http://master.php.net/manage/user-notes.php