note 87421 added to function.strftime
| From: | lamb dot dan at gmail dot com | Date: | Thu, 04 Dec 2008 18:37:26 +0000 |
| Subject: | note 87421 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147636@lists.php.net to get a copy of this message | ||
<?php
/*
* This function figures out what fiscal year a specified date is in.
* $inputDate - the date you wish to find the fiscal year for. (12/4/08)
* $fyStartDate - the month and day your fiscal year starts. (7/1)
* $fyEndDate - the month and day your fiscal year ends. (6/30)
* $fy - returns the correct fiscal year
*/
function calculateFiscalYearForDate($inputDate, $fyStart, $fyEnd){
$date = strtotime($inputDate);
$inputyear = strftime('%Y',$date);
$fystartdate = strtotime($fyStart.$inputyear);
$fyenddate = strtotime($fyEnd.$inputyear);
if($date < $fyenddate){
$fy = intval($inputyear);
}else{
$fy = intval(intval($inputyear) + 1);
}
return $fy;
}
// my fiscal year starts on July,1 and ends on June 30, so...
echo calculateFiscalYearForDate("5/15/08","7/1","6/30");
// returns 2008
echo calculateFiscalYearForDate("12/1/08","7/1","6/30");
// returns 2009
?>
----
Server IP: 64.71.164.2
Probable Submitter: 192.153.163.59
----
Manual Page -- http://www.php.net/manual/en/function.strftime.php
Edit -- https://master.php.net/note/edit/87421
Del: integrated -- https://master.php.net/note/delete/87421/integrated
Del: useless -- https://master.php.net/note/delete/87421/useless
Del: bad code -- https://master.php.net/note/delete/87421/bad+code
Del: spam -- https://master.php.net/note/delete/87421/spam
Del: non-english -- https://master.php.net/note/delete/87421/non-english
Del: in docs -- https://master.php.net/note/delete/87421/in+docs
Del: other reasons-- https://master.php.net/note/delete/87421
Reject -- https://master.php.net/note/reject/87421
Search -- https://master.php.net/manage/user-notes.php